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

Re: bug with completion (after 15 oct?)



Geoff Wing wrote:

> ...
> 
> # then do
> ls ba<TAB><CTRL-U>ls ba<TAB><CTRL-U>ls ba<TAB>
> # core dump

Aha. It didn't find out that it had a new list. The patch adds a
counter counting how often we have invalidated a completion list and
then uses that counter to find out if the list displayed is the same
as before.

Bye
 Sven

Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.35
diff -u -r1.35 complist.c
--- Src/Zle/complist.c	2000/10/24 07:50:24	1.35
+++ Src/Zle/complist.c	2000/10/25 08:17:03
@@ -986,7 +986,7 @@
 static int
 compprintlist(int showall)
 {
-    static int lasttype = 0, lastbeg = 0, lastml = 0;
+    static int lasttype = 0, lastbeg = 0, lastml = 0, lastinvcount = -1;
     static int lastn = 0, lastnl = 0, lastnlnct = -1;
     static Cmgroup lastg = NULL;
     static Cmatch *lastp = NULL;
@@ -999,7 +999,7 @@
     int lastused = 0;
 
     mfirstl = -1;
-    if (mnew || lastbeg != mlbeg || mlbeg < 0) {
+    if (mnew || lastinvcount != invcount || lastbeg != mlbeg || mlbeg < 0) {
 	lasttype = 0;
 	lastg = NULL;
 	lastexpl = NULL;
@@ -1010,6 +1010,7 @@
 	  lines - nlnct - mhasstat : listdat.nlines) - (lastnlnct > nlnct);
     lastnlnct = nlnct;
     mrestlines = lines - 1;
+    lastinvcount = invcount;
 
     if (cl < 2) {
 	cl = -1;
Index: Src/Zle/compresult.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compresult.c,v
retrieving revision 1.26
diff -u -r1.26 compresult.c
--- Src/Zle/compresult.c	2000/10/24 07:50:25	1.26
+++ Src/Zle/compresult.c	2000/10/25 08:17:03
@@ -30,6 +30,12 @@
 #include "complete.mdh"
 #include "compresult.pro"
 
+/* This counts how often the list of completions was invalidated.
+ * Can be used to detect if we have a new list.  */
+
+/**/
+mod_export int invcount;
+
 #define inststr(X) inststrlen((X),1,-1)
 
 /* This cuts the cline list before the stuff that isn't worth
@@ -1264,6 +1270,8 @@
 mod_export int
 calclist(int showall)
 {
+    static int lastinvcount = -1;
+
     Cmgroup g;
     Cmatch *p, m;
     Cexpl *e;
@@ -1271,10 +1279,12 @@
     int max = 0, i;
     VARARR(int, mlens, nmatches + 1);
 
-    if (listdat.valid && onlyexpl == listdat.onlyexpl &&
+    if (lastinvcount == invcount &&
+	listdat.valid && onlyexpl == listdat.onlyexpl &&
 	menuacc == listdat.menuacc && showall == listdat.showall &&
 	lines == listdat.lines && columns == listdat.columns)
 	return 0;
+    lastinvcount = invcount;
 
     for (g = amatches; g; g = g->next) {
 	char **pp = g->ylist;
@@ -2089,6 +2099,7 @@
 mod_export int
 invalidate_list(void)
 {
+    invcount++;
     if (validlist) {
 	if (showinglist == -2)
 	    zrefresh();

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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