Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: BUG: Matching cause character to be deleted.
- X-seq: zsh-workers 10924
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: Re: BUG: Matching cause character to be deleted.
- Date: Wed, 26 Apr 2000 08:32:54 +0200 (MET DST)
- In-reply-to: Felix Rosencrantz's message of Thu, 20 Apr 2000 17:47:58 -0700 (PDT)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
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> #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@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author