From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2833 invoked from network); 26 Apr 2000 06:33:03 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 26 Apr 2000 06:33:03 -0000 Received: (qmail 11201 invoked by alias); 26 Apr 2000 06:32:57 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10924 Received: (qmail 11189 invoked from network); 26 Apr 2000 06:32:56 -0000 Date: Wed, 26 Apr 2000 08:32:54 +0200 (MET DST) Message-Id: <200004260632.IAA09728@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Felix Rosencrantz's message of Thu, 20 Apr 2000 17:47:58 -0700 (PDT) Subject: PATCH: Re: BUG: Matching cause character to be deleted. Felix Rosencrantz wrote: > ... > > I found this bug, which is pruned down. > > myprompt@ zsh -f > host% mkdir j > host% touch j/{BW,UWB,W} > host% bindkey -e; autoload -U compinit; compinit -D > host% zstyle ':completion:*:complete:*' matcher-list 'r:|[A-Z0-9]=*' > host% ls j/W #Tab deletes the W, so the line looks like this: > host% ls j/ Here is the fix. The main problem was that it didn't correctly mark the cline structs for which there was something on the line (in particular: the cline structs for the `W'). And then I made merging two cline lists a bit cleverer, trying harder to find corresponding elements. Bye Sven Index: Src/Zle/compmatch.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/compmatch.c,v retrieving revision 1.6 diff -u -r1.6 compmatch.c --- Src/Zle/compmatch.c 2000/04/18 07:07:30 1.6 +++ Src/Zle/compmatch.c 2000/04/26 06:29:44 @@ -1018,7 +1018,7 @@ * is set if the characters before the anchor were not * on the line. */ *q = n = get_cline(NULL, mp->ralen, str, mp->ralen, NULL, 0, - ((plen < 0) ? CLF_NEW : 0)); + ((plen <= 0) ? CLF_NEW : 0)); /* If there were any characters before the anchor, add * them as a cline struct. */ @@ -1046,7 +1046,7 @@ } /* This is the cline struct for the remaining string at the end. */ - *q = n = get_cline(NULL, 0, NULL, 0, NULL, 0, (plen < 0 ? CLF_NEW : 0)); + *q = n = get_cline(NULL, 0, NULL, 0, NULL, 0, (plen <= 0 ? CLF_NEW : 0)); if (p != str) { int olen = str - p, llen = (op < 0 ? 0 : op); @@ -1843,9 +1843,25 @@ } /* Now see if they have matching anchors. If not, cut the list. */ if (!(o->flags & CLF_MID) && !cmp_anchors(o, n, 1)) { - Cline t, tn; + Cline t, tn, tt, to = NULL; - for (t = n; (tn = t->next) && !cmp_anchors(o, tn, 1); t = tn); + for (t = n; (tn = t->next); t = tn) + if (!(tn->flags & CLF_NEW)) { + for (tt = o; (to = tt->next); tt = to) + if (!(to->flags & CLF_NEW) && + cmp_anchors(tn, to, 1)) + break; + if (to) + break; + } + if (tn) { + if (po) + po->next = to; + 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); @@ -1864,8 +1880,6 @@ n = n->next; continue; } else { - Cline to; - for (t = o; (to = t->next) && !cmp_anchors(n, to, 1); t = to); @@ -1887,9 +1901,7 @@ } continue; } else { - Cline tt = NULL; - - for (t = n; (tn = t->next); t = tn) { + for (tt = NULL, t = n; (tn = t->next); t = tn) { for (tt = o; (to = tt->next) && !cmp_anchors(tn, to, 1); tt = to); -- Sven Wischnowsky wischnow@informatik.hu-berlin.de