From 9af83c6c2a54f479864698762c4a3cab5aba2fa8 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Wed, 10 Jan 2001 09:24:45 +0000 Subject: fix cursor positioning with partial-word match specs using `**' (13336) --- ChangeLog | 6 +++++ Src/Zle/compmatch.c | 61 +++++++++++++++++++++++++++++---------------------- Src/Zle/compresult.c | 14 +++++++----- Test/54compmatch.ztst | 4 ++-- 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2b771cbd..0e4b84158 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-01-10 Sven Wischnowsky + + * 13336: Src/Zle/compmatch.c, Src/Zle/compresult.c, + Test/54compmatch.ztst: fix cursor positioning with partial-word + match specs using `**' + 2001-01-08 Sven Wischnowsky * 13331: Src/Zle/compcore.c, Src/Zle/compresult.c: fix for diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c index bdc9d99d6..5a46a2616 100644 --- a/Src/Zle/compmatch.c +++ b/Src/Zle/compmatch.c @@ -416,13 +416,32 @@ add_match_sub(Cmatcher m, char *l, int ll, char *w, int wl) /* And add the cline. */ if (wl || ll) { - n = get_cline(l, ll, w, wl, NULL, 0, - flags | ((m && m->wlen == -2) ? CLF_SKIP : 0)); - if (matchlastsub) - matchlastsub->next = n; - else - matchsubs = n; - matchlastsub = n; + Cline p, lp; + + if ((p = n = bld_parts(w, wl, ll, &lp)) && n != lp) { + for (; p->next != lp; p = p->next); + + if (matchsubs) { + matchlastsub->next = n->prefix; + n->prefix = matchsubs; + } + matchsubs = matchlastsub = lp; + + if (matchlastpart) + matchlastpart->next = n; + else + matchparts = n; + p->next = 0; + matchlastpart = p; + } else { + n = get_cline(l, ll, w, wl, NULL, 0, + flags | ((m && m->wlen == -2) ? CLF_SKIP : 0)); + if (matchlastsub) + matchlastsub->next = n; + else + matchsubs = n; + matchlastsub = n; + } } } @@ -792,7 +811,6 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp, add_match_sub(NULL, NULL, 0, w, ow - w); else add_match_sub(NULL, NULL, 0, ow, w - ow); - add_match_sub(mp, tl, mp->llen, tw, mp->wlen); } if (sfx) { @@ -1870,31 +1888,29 @@ join_clines(Cline o, Cline n) if ((o->flags & CLF_NEW) && !(n->flags & CLF_NEW)) { Cline t, tn; - for (t = o; (tn = t->next) && (tn->flags & CLF_NEW); t = tn); - if (tn && cmp_anchors(tn, n, 0)) { + for (t = o; (tn = t->next) && + ((tn->flags & CLF_NEW) || !cmp_anchors(tn, n, 0)); + t = tn); + if (tn) { diff = sub_join(n, o, tn, 1); if (po) po->next = tn; else oo = tn; + t->next = NULL; 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; } } @@ -1907,19 +1923,13 @@ join_clines(Cline o, Cline n) if (tn) { 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; } @@ -1989,13 +1999,13 @@ join_clines(Cline o, Cline n) else oo = to; o = to; - } else - for (t = n; (tn = t->next) && !cmp_anchors(o, tn, 1); t = tn); - + } if (tn) { diff = sub_join(o, n, tn, 0); + o->flags |= CLF_MISS; o->max += diff; + n = tn; po = o; o = o->next; @@ -2099,4 +2109,3 @@ join_clines(Cline o, Cline n) return oo; } } - diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c index f30d8259a..287e1509f 100644 --- a/Src/Zle/compresult.c +++ b/Src/Zle/compresult.c @@ -163,13 +163,14 @@ static char * cline_str(Cline l, int ins, int *csp) { Cline s; - int ocs = cs, ncs, pcs, scs, pm, pmax, pmm, sm, smax, smm, d, dm, mid; + int ocs = cs, ncs, pcs, scs; + int pm, pmax, pmm, pma, sm, smax, smm, sma, d, dm, mid; int i, j, li = 0, cbr; Brinfo brp, brs; l = cut_cline(l); - pmm = smm = dm = pcs = scs = 0; + pmm = pma = smm = sma = dm = pcs = scs = 0; pm = pmax = sm = smax = d = mid = cbr = -1; brp = brs = NULL; @@ -242,9 +243,11 @@ cline_str(Cline l, int ins, int *csp) /* Remember the position if this is the first prefix with * missing characters. */ if ((l->flags & CLF_MISS) && !(l->flags & CLF_SUF) && - ((pmax < (l->min - l->max) && (!pmm || (l->flags & CLF_MATCHED))) || + (((pmax < (l->max - l->min) || (pma && l->max != l->min)) && + (!pmm || (l->flags & CLF_MATCHED))) || ((l->flags & CLF_MATCHED) && !pmm))) { - pm = cs; pmax = l->min - l->max; pmm = l->flags & CLF_MATCHED; + pm = cs; pmax = l->max - l->min; pmm = l->flags & CLF_MATCHED; + pma = ((l->prefix || l->suffix) && l->min == cline_sublen(l)); } if (ins) { int ocs, bl; @@ -289,10 +292,11 @@ cline_str(Cline l, int ins, int *csp) if (l->flags & CLF_MID) mid = cs; else if ((l->flags & CLF_SUF) && - ((smax < (l->min - l->max) && + (((smax < (l->min - l->max) || (sma && l->max != l->min)) && (!smm || (l->flags & CLF_MATCHED))) || ((l->flags & CLF_MATCHED) && !smm))) { sm = cs; smax = l->min - l->max; smm = l->flags & CLF_MATCHED; + sma = ((l->prefix || l->suffix) && l->min == cline_sublen(l)); } } if (ins) { diff --git a/Test/54compmatch.ztst b/Test/54compmatch.ztst index 0807a10c1..e96b2c9a0 100644 --- a/Test/54compmatch.ztst +++ b/Test/54compmatch.ztst @@ -414,9 +414,9 @@ test_code 'r:|[A-Z0-9]=** r:|=*' example6_list comptest $'tst 2\t\t' 0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input 2 ->line: {tst 523}{} +>line: {tst 5}{23} >COMPADD:{} ->line: {tst 523}{} +>line: {tst 5}{23} >COMPADD:{} >NO:{5bar234} >NO:{5foo123} -- cgit 1.4.1