about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-01-24 15:34:37 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-01-24 15:34:37 +0000
commit1464043a323616c9bfc1d7b0421b5a6b26955c05 (patch)
tree31ac6e2d70481e6d3d58aa00bb384375b77ef0a2
parenta94182714da04d5f8f6a47edb417fe319b3887d9 (diff)
downloadzsh-1464043a323616c9bfc1d7b0421b5a6b26955c05.tar.gz
zsh-1464043a323616c9bfc1d7b0421b5a6b26955c05.tar.xz
zsh-1464043a323616c9bfc1d7b0421b5a6b26955c05.zip
zsh-workers/9419
-rw-r--r--Src/Zle/complist.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 39eee8b85..235012ee3 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -391,7 +391,8 @@ static struct listcols mcolors;
 
 static int nrefs;
 static int begpos[MAX_POS], curisbeg;
-static int endpos[MAX_POS], curisend;
+static int endpos[MAX_POS];
+static int sendpos[MAX_POS], curissend; /* sorted end positions */
 static char **patcols, *curiscols[MAX_POS];
 static int curiscol;
 
@@ -450,29 +451,45 @@ initiscol(Listcols c)
 
     curiscols[curiscol = 0] = *patcols++;
 
-    curisbeg = curisend = 0;
+    curisbeg = curissend = 0;
 
-    for (i = nrefs;  i < MAX_POS; i++)
-	begpos[i] = endpos[i] = -1;
+    for (i = 0; i < nrefs; i++)
+	sendpos[i] = 0xfffffff;
+    for (; i < MAX_POS; i++)
+	begpos[i] = endpos[i] = sendpos[i] = 0xfffffff;
 }
 
 static void
 doiscol(Listcols c, int pos)
 {
-    if (endpos[curisend] >= 0 && pos > endpos[curisend]) {
-	curisend++;
+    int fi;
+
+    while (pos > sendpos[curissend]) {
+	curissend++;
 	if (curiscol) {
 	    zcputs(c, NULL, COL_NO);
 	    zlrputs(c, curiscols[--curiscol]);
 	}
     }
-    if (pos == begpos[curisbeg] && *patcols) {
-	curisbeg++;
-
-	zcputs(c, NULL, COL_NO);
-	zlrputs(c, *patcols);
-
-	curiscols[++curiscol] = *patcols++;
+    while (((fi = (endpos[curisbeg] < begpos[curisbeg] || 
+		  begpos[curisbeg] == -1)) ||
+	    pos == begpos[curisbeg]) && *patcols) {
+	if (!fi) {
+	    int i, j, e = endpos[curisbeg];
+	    
+	    /* insert e in sendpos */
+	    for (i = curissend; sendpos[i] <= e; ++i)
+		;
+	    for (j = i + 1; j < MAX_POS; ++j)
+		sendpos[j] = sendpos[j-1];
+	    sendpos[i] = e;
+	    
+	    zcputs(c, NULL, COL_NO);
+	    zlrputs(c, *patcols);
+	    curiscols[++curiscol] = *patcols;
+	}
+	++patcols;
+	++curisbeg;
     }
 }