Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: completion matching



Playing with what Jay described in his last message showed two bugs in 
the completion matching code:

With his directory structure, `u/q/a<TAB>' removed the `q/'. That was
caused by a wrong path-prefix matching.

And `../com/cor' with the cursor on the first `c' inserted something
funny (`C', `om' and `pletion', but in reverse order). This was caused 
by giving the wrong value to the `suffix' argument of add_match_str()
in two places.

Bye
 Sven

Index: Src/Zle/compmatch.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compmatch.c,v
retrieving revision 1.26
diff -u -r1.26 compmatch.c
--- Src/Zle/compmatch.c	2000/10/10 13:37:31	1.26
+++ Src/Zle/compmatch.c	2000/10/13 08:38:26
@@ -498,7 +498,7 @@
 	 */
 
 	bslash = 0;
-	if (!sfx && lw &&
+	if (!sfx && lw && (!part || test) &&
 	    (l[ind] == w[ind] ||
 	     (bslash = (lw > 1 && w[ind] == '\\' &&
 			(ind ? (w[0] == l[0]) : (w[1] == l[0])))))) {
@@ -784,10 +784,10 @@
 		    /* Probably add the matched strings. */
 		    if (!test) {
 			if (sfx)
-			    add_match_str(NULL, NULL, w, ow - w, 0);
+			    add_match_str(NULL, NULL, w, ow - w, sfx);
 			else
-			    add_match_str(NULL, NULL, ow, w - ow, 0);
-			add_match_str(mp, tl, tw, mp->wlen, 0);
+			    add_match_str(NULL, NULL, ow, w - ow, sfx);
+			add_match_str(mp, tl, tw, mp->wlen, sfx);
 			if (sfx)
 			    add_match_sub(NULL, NULL, 0, w, ow - w);
 			else
@@ -846,7 +846,7 @@
 	    if (!lw)
 		break;
 
-	    if (exact) {
+	    if (exact && !part) {
 		/* If we just accepted some characters directly (at the
 		 * beginning of the loop) and now can't match any further,
 		 * we go back to before those characters and try again,

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author