zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Re: BUG: Matching cause character to be deleted.
@ 2000-04-26  6:32 Sven Wischnowsky
  0 siblings, 0 replies; only message in thread
From: Sven Wischnowsky @ 2000-04-26  6:32 UTC (permalink / raw)
  To: zsh-workers


Felix Rosencrantz wrote:

> ...
> 
> I found this bug, which is pruned down.
> 
> myprompt@ zsh -f
> host% mkdir j
> host% touch j/{BW,UWB,W} 
> host% bindkey -e; autoload -U compinit; compinit -D
> host% zstyle ':completion:*:complete:*' matcher-list 'r:|[A-Z0-9]=*'
> host% ls j/W<TAB>  #Tab deletes the W, so the line looks like this:
> host% ls j/ 

Here is the fix. The main problem was that it didn't correctly mark
the cline structs for which there was something on the line (in
particular: the cline structs for the `W').

And then I made merging two cline lists a bit cleverer, trying harder
to find corresponding elements.

Bye
 Sven

Index: Src/Zle/compmatch.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compmatch.c,v
retrieving revision 1.6
diff -u -r1.6 compmatch.c
--- Src/Zle/compmatch.c	2000/04/18 07:07:30	1.6
+++ Src/Zle/compmatch.c	2000/04/26 06:29:44
@@ -1018,7 +1018,7 @@
 		 * is set if the characters before the anchor were not
 		 * on the line. */
 		*q = n = get_cline(NULL, mp->ralen, str, mp->ralen, NULL, 0,
-				   ((plen < 0) ? CLF_NEW : 0));
+				   ((plen <= 0) ? CLF_NEW : 0));
 
 		/* If there were any characters before the anchor, add
 		 * them as a cline struct. */
@@ -1046,7 +1046,7 @@
     }
     /* This is the cline struct for the remaining string at the end. */
 
-    *q = n = get_cline(NULL, 0, NULL, 0, NULL, 0, (plen < 0 ? CLF_NEW : 0));
+    *q = n = get_cline(NULL, 0, NULL, 0, NULL, 0, (plen <= 0 ? CLF_NEW : 0));
     if (p != str) {
 	int olen = str - p, llen = (op < 0 ? 0 : op);
 
@@ -1843,9 +1843,25 @@
 	    }
 	    /* Now see if they have matching anchors. If not, cut the list. */
 	    if (!(o->flags & CLF_MID) && !cmp_anchors(o, n, 1)) {
-		Cline t, tn;
+		Cline t, tn, tt, to = NULL;
 
-		for (t = n; (tn = t->next) && !cmp_anchors(o, tn, 1); t = tn);
+		for (t = n; (tn = t->next); t = tn)
+		    if (!(tn->flags & CLF_NEW)) {
+			for (tt = o; (to = tt->next); tt = to)
+			    if (!(to->flags & CLF_NEW) &&
+				cmp_anchors(tn, to, 1))
+				break;
+			if (to)
+			    break;
+		    }
+		if (tn) {
+		    if (po)
+			po->next = to;
+		    else
+			oo = to;
+		    o = to;
+		} else
+		    for (t = n; (tn = t->next) && !cmp_anchors(o, tn, 1); t = tn);
 
 		if (tn) {
 		    diff = sub_join(o, n, tn, 0);
@@ -1864,8 +1880,6 @@
 		    n = n->next;
 		    continue;
 		} else {
-		    Cline to;
-
 		    for (t = o; (to = t->next) && !cmp_anchors(n, to, 1);
 			 t = to);
 
@@ -1887,9 +1901,7 @@
 			}
 			continue;
 		    } else {
-			Cline tt = NULL;
-
-			for (t = n; (tn = t->next); t = tn) {
+			for (tt = NULL, t = n; (tn = t->next); t = tn) {
 			    for (tt = o;
 				 (to = tt->next) &&
 				     !cmp_anchors(tn, to, 1); tt = to);

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-04-26  6:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-26  6:32 PATCH: Re: BUG: Matching cause character to be deleted Sven Wischnowsky

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).