Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: _prefix clearing the word

zstyle ':completion:*' completer _complete _prefix
cd /usr/lo<tab>oc

and the whole word disappears.

This problem relates back to the change in 15357. That change was a
fairly nasty hack: to prevent the cursor going to the end of the suffix
if there is one match a second match is added which is the same as
the first (${compstate[unambiguous]}) with the suffix chopped off and an
`x' added. This results in an ambiguous completion so the cursor doesn't
advance past the suffix.

Now in this particular case, it gets an ambiguous completion where the
common part is nothing. I have no idea why but it probably has something
to do with the first match being added with some special case stuff
(compadd -Qf -p /usr/ -W /usr/).

Best I can think of is the patch below. If adding the second match
results in ${compstate[unambiguous]} being empty then insert the first
match. Seems to work quite well but I wouldn't be suprised if we need to
patch more things onto the side of this.

By the way, the bug mentioned in 17846 is still an issue. Not really related
to _prefix but it was through that that I was reminded.


Index: Completion/Base/Completer/_prefix
RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_prefix,v
retrieving revision 1.2
diff -u -r1.2 _prefix
--- Completion/Base/Completer/_prefix	10 Jul 2001 09:25:43 -0000	1.2
+++ Completion/Base/Completer/_prefix	9 Jul 2003 15:23:59 -0000
@@ -48,7 +48,11 @@
       [[ compstate[nmatches] -gt 1 ]] && return 0
       compadd -U -i "$IPREFIX" -I "$ISUFFIX" - "${compstate[unambiguous]%$suf}x"
-      compstate[insert]=unambiguous
+      if [[ -n $compstate[unambiguous] ]]; then
+        compstate[insert]=unambiguous
+      else
+        compstate[insert]=0
+      fi
       return 0
     (( _matcher_num++ ))

This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit

Messages sorted by: Reverse Date, Date, Thread, Author