zsh-workers
 help / color / mirror / code / Atom feed
* Re: completion problem with matching control.
@ 1999-07-19 13:39 Sven Wischnowsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 1999-07-19 13:39 UTC (permalink / raw)
  To: zsh-workers


Tanaka Akira wrote:

> I found a problem about completion with matching control.
> 
> Z:akr@is27e1u11% zsh-3.1.6-test-1 -f
> is27e1u11% autoload -U compinit
> is27e1u11% compinit -D
> is27e1u11% _tst () { compadd -P b A; compadd -P c A }
> is27e1u11% compdef -a _tst tst
> is27e1u11% compctl -M m:\{a-z\}\=\{A-Z\}
> is27e1u11% tst a<TAB>
> 
> Then, "a" is deleted.

The problem is in the different -P prefixes, not in the matching. The
completion code stuffed all prefixes and all suffixes together and adds 
them to the string itself, so that things still work even if for one
match a string-part is in one prefix and for another match the same
string is in a different prefix. However, -P is slightly different
since it doesn't `come from the line'. So this patch tries to keep the 
old behavior if possible and otherwise adds the prefixes one by one.

Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Thu Jul 15 16:01:50 1999
+++ Src/Zle/zle_tricky.c	Mon Jul 19 15:38:54 1999
@@ -3527,7 +3527,9 @@
 		p->next = qsl;
 	}
     }
-    /* And the same for the prefix. */
+    /* The prefix is handled differently because the completion code
+     * is much more eager to insert the -P prefix than it is to insert
+     * the -S suffix. */
     if (qipre)
 	palen = (qipl = strlen(qipre));
     if (ipre)
@@ -3537,7 +3539,49 @@
     if (ppre)
 	palen += (ppl = strlen(ppre));
 
-    if (palen) {
+    if (pl) {
+	if (ppl) {
+	    Cline lp, p = bld_parts(ppre, ppl, ppl, &lp);
+
+	    if (lp->prefix && !(line->flags & (CLF_SUF | CLF_MID))) {
+		lp->prefix->next = line->prefix;
+		line->prefix = lp->prefix;
+		lp->prefix = NULL;
+
+		free_cline(lp);
+
+		if (p != lp) {
+		    Cline q;
+
+		    for (q = p; q->next != lp; q = q->next);
+
+		    q->next = line;
+		    line = p;
+		}
+	    } else {
+		lp->next = line;
+		line = p;
+	    }
+	}
+	if (pl) {
+	    Cline lp, p = bld_parts(pre, pl, pl, &lp);
+
+	    lp->next = line;
+	    line = p;
+	}
+	if (ipl) {
+	    Cline lp, p = bld_parts(ipre, ipl, ipl, &lp);
+
+	    lp->next = line;
+	    line = p;
+	}
+	if (qipl) {
+	    Cline lp, p = bld_parts(qipre, qipl, qipl, &lp);
+
+	    lp->next = line;
+	    line = p;
+	}
+    } else if (palen) {
 	char *apre = (char *) zhalloc(palen);
 	Cline p, lp;
 

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 2+ messages in thread

* completion problem with matching control.
@ 1999-07-18  1:39 Tanaka Akira
  0 siblings, 0 replies; 2+ messages in thread
From: Tanaka Akira @ 1999-07-18  1:39 UTC (permalink / raw)
  To: zsh-workers

I found a problem about completion with matching control.

Z:akr@is27e1u11% zsh-3.1.6-test-1 -f
is27e1u11% autoload -U compinit
is27e1u11% compinit -D
is27e1u11% _tst () { compadd -P b A; compadd -P c A }
is27e1u11% compdef -a _tst tst
is27e1u11% compctl -M m:\{a-z\}\=\{A-Z\}
is27e1u11% tst a<TAB>

Then, "a" is deleted.
-- 
Tanaka Akira


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-07-19 13:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-19 13:39 completion problem with matching control Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
1999-07-18  1:39 Tanaka Akira

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).