Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: cursor position after completion
- X-seq: zsh-workers 7630
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: cursor position after completion
- Date: Thu, 2 Sep 1999 13:06:03 +0200 (MET DST)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
With `option_prefix=yes' and a global match spec `r:|-=*' trying
completion on things like `pnmpad -<TAB>' in a directory like the zsh
`Src' directory gives you the options and all files containing a
hyphen. Then the completion code positions the cursor on the first
place where characters are missing which is before (on) the `-' in
this case.
Since this has annoyed me for too long now, the patch below makes the
cursor be placed on the last position where characters are missing or
differ. I hope that this gets it right in more cases than the previous
code, although it isn't perfect either. Unfortunately, placing it at
the position where the greatest number of matches differ is impossible
since we can't really detect this without comparing the parts of all
matches separately, which is too expensive.
Bye
Sven
diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c Thu Sep 2 11:39:18 1999
+++ Src/Zle/zle_tricky.c Thu Sep 2 12:59:52 1999
@@ -7348,7 +7348,7 @@
inststrlen(s->line, 1, s->llen);
else
inststrlen(s->word, 1, s->wlen);
- if (d < 0 && (s->flags & CLF_DIFF))
+ if (s->flags & CLF_DIFF)
d = cs;
if (ins) {
li += s->llen;
@@ -7363,7 +7363,7 @@
}
/* Remember the position if this is the first prefix with
* missing characters. */
- if (pm < 0 && (l->flags & CLF_MISS) && !(l->flags & CLF_SUF))
+ if ((l->flags & CLF_MISS) && !(l->flags & CLF_SUF))
pm = cs;
pcs = cs;
/* Insert the anchor. */
@@ -7384,7 +7384,7 @@
if (l->flags & CLF_MISS) {
if (l->flags & CLF_MID)
b = cs;
- else if (sm < 0 && (l->flags & CLF_SUF))
+ else if (l->flags & CLF_SUF)
sm = cs;
}
/* And now insert the suffix or the original string. */
@@ -7402,10 +7402,11 @@
}
} else {
int hp = 0, hs = 0;
+ Cline js = NULL;
for (j = -1, i = 0, s = l->suffix; s; s = s->next) {
if (j < 0 && (s->flags & CLF_DIFF))
- j = i;
+ j = i, js = s;
if (s->flags & CLF_LINE) {
inststrlen(s->line, 0, s->llen);
i += s->llen; pcs = cs + s->llen;
@@ -7428,7 +7429,7 @@
if (hs)
spos += i;
cs += i;
- if (d < 0 && j >= 0)
+ if (j >= 0)
d = cs - j;
}
/* If we reached the right positions, re-insert the braces. */
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author