diff options
author | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-05-12 11:52:30 +0000 |
---|---|---|
committer | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-05-12 11:52:30 +0000 |
commit | 984bae21ba24710ff1fd24a8b9271ca4c89efbb4 (patch) | |
tree | a97700bd94da18af12fd71d1d28cf2b483907dcb /Src | |
parent | 6472a2b7bc524fbe3f543a41e8991e82e2580443 (diff) | |
download | zsh-984bae21ba24710ff1fd24a8b9271ca4c89efbb4.tar.gz zsh-984bae21ba24710ff1fd24a8b9271ca4c89efbb4.tar.xz zsh-984bae21ba24710ff1fd24a8b9271ca4c89efbb4.zip |
fixes for completion matching (11346)
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Zle/compmatch.c | 23 | ||||
-rw-r--r-- | Src/Zle/compresult.c | 31 |
2 files changed, 50 insertions, 4 deletions
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c index 682994fdd..fe9dad41b 100644 --- a/Src/Zle/compmatch.c +++ b/Src/Zle/compmatch.c @@ -466,7 +466,9 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp, bp->curpos = bc; bp = bp->next; } - while (ll && lw) { + /*** This once was: `while (ll && lw)', but then ignored characters at + * the end or not, well, ignored. */ + while (ll) { /* Hm, we unconditionally first tried the matchers for the cases * where the beginnings of the line and word patterns match the @@ -576,7 +578,12 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp, pattern_match(ap, tp - moff, NULL, NULL) && (!aol || pattern_match(aop, tp - moff - aol, NULL, NULL)) && - match_parts(l + aoff , tp - moff, alen, part))) { + (mp->wlen == -1 || + match_parts(l + aoff , tp - moff, + alen, part)))) { + if (!both && mp->wlen == -1 && + !match_parts(l + aoff , tp - moff, alen, part)) + break; if (sfx) { savw = tp[-zoff]; tp[-zoff] = '\0'; @@ -1819,13 +1826,19 @@ join_clines(Cline o, Cline n) free_cline(o); x = o; o = tn; +#if 0 + /*** These should be handled different from the ones + that compare anchors. */ if (po && po->prefix && cmp_anchors(x, po, 0)) { po->flags |= CLF_MISS; po->max += diff; } else { +#endif o->flags |= CLF_MISS; o->max += diff; +#if 0 } +#endif continue; } } @@ -1836,13 +1849,19 @@ join_clines(Cline o, Cline n) if (tn && cmp_anchors(o, tn, 0)) { diff = sub_join(o, n, tn, 0); +#if 0 + /*** These should be handled different from the ones + that compare anchors. */ if (po && po->prefix && cmp_anchors(n, pn, 0)) { po->flags |= CLF_MISS; po->max += diff; } else { +#endif o->flags |= CLF_MISS; o->max += diff; +#if 0 } +#endif n = tn; continue; } 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); |