about summary refs log tree commit diff
path: root/Src/Zle/compresult.c
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-12 11:52:30 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-12 11:52:30 +0000
commit984bae21ba24710ff1fd24a8b9271ca4c89efbb4 (patch)
treea97700bd94da18af12fd71d1d28cf2b483907dcb /Src/Zle/compresult.c
parent6472a2b7bc524fbe3f543a41e8991e82e2580443 (diff)
downloadzsh-984bae21ba24710ff1fd24a8b9271ca4c89efbb4.tar.gz
zsh-984bae21ba24710ff1fd24a8b9271ca4c89efbb4.tar.xz
zsh-984bae21ba24710ff1fd24a8b9271ca4c89efbb4.zip
fixes for completion matching (11346)
Diffstat (limited to 'Src/Zle/compresult.c')
-rw-r--r--Src/Zle/compresult.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index 1e6140687..5537f88ce 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -40,7 +40,7 @@ static Cline
 cut_cline(Cline l)
 {
     Cline q, p, e = NULL, maxp = NULL;
-    int sum = 0, max = 0, tmp, ls = 0;
+    int sum = 0, max = 0, tmp, ls = 0, miss = 0;
 
     /* If no match was added with matching, we don't really know
      * which parts of the unambiguous string are worth keeping,
@@ -108,13 +108,40 @@ cut_cline(Cline l)
 		    len += p->max;
 
 		if (len > ((minmlen << 1) / 3))
-		    return l;
+		    goto end;
 	    }
 	    e->line = e->word = NULL;
 	    e->llen = e->wlen = e->olen = 0;
 	    e->next = NULL;
 	}
     }
+ end:
+
+    /* Sanity check. If there are no parts with missing characters but
+     * parts with joined substrings, remove those. */
+
+    for (p = l, e = 0, tmp = 0; p; p = p->next) {
+	if (p->flags & (CLF_MISS|CLF_DIFF))
+	    miss = 1;
+	for (q = p->prefix; q; q = q->next)
+	    if (q->flags & CLF_JOIN) {
+		e = p;
+		tmp = 0;
+		break;
+	    }
+	for (q = p->suffix; q; q = q->next)
+	    if (q->flags & CLF_JOIN) {
+		e = p;
+		tmp = 1;
+		break;
+	    }
+    }
+    if (e && (!miss || cline_sublen(e) == e->min)) {
+	for (p = (tmp ? e->suffix : e->prefix);
+	     p && p->next && !(p->next->flags & CLF_JOIN); p = p->next);
+	if (p)
+	    p->next = NULL;
+    }
     if (!ls)
 	cline_setlens(l, 0);