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

PATCH: Re: Bad Variable Completion in test-2



Vin Shelton wrote:

> There seems to be a bug in accept-and-menu-complete in test-2:
> 
> : ~ Tue 20 0:51; /usr/local/zsh-3.1.6-test-2/bin/zsh -f
> mithril% bindkey '^X\t' accept-and-menu-complete
> mithril% echo $ZSH_<TAB><TAB>^X<TAB>
> 
> This results in:
> 
> mithril% echo $ZSH_NAME $$ZSH_VERSION
> 
> Note the '$$' - not what was intended.

That's with old style completion. The patch also fixes a problem with
new style completion when the match had a suffix.

Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Tue Jul 20 08:54:19 1999
+++ Src/Zle/zle_tricky.c	Tue Jul 20 10:28:06 1999
@@ -565,8 +565,9 @@
 	cs = minfo.pos + minfo.len + minfo.insc;
 	iremovesuffix(' ', 1);
 	l = cs;
-	cs = minfo.pos + minfo.len - (*(minfo.cur))->qisl;
-	foredel(l - cs);
+	cs = minfo.pos + minfo.len + minfo.insc - (*(minfo.cur))->qisl;
+	if (cs < l)
+	    foredel(l - cs);
 	inststrlen(" ", 1, 1);
 	if (parpre)
 	    inststr(parpre);
@@ -801,11 +802,12 @@
 		parq = eparq = 0;
 
 	    /* Save the prefix. */
-	    sav = *b;
-	    *b = '\0';
-	    untokenize(parpre = ztrdup(s));
-	    *b = sav;
-
+	    if (incompfunc) {
+		sav = *b;
+		*b = '\0';
+		untokenize(parpre = ztrdup(s));
+		*b = sav;
+	    }
 	    /* And adjust wb, we, and offs again. */
 	    offs -= b - s;
 	    wb = cs - offs;

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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