about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorMarlon Richert <marlon.richert@gmail.com>2023-06-22 13:13:09 -0700
committerBart Schaefer <schaefer@zsh.org>2023-06-22 13:13:09 -0700
commit6c993144bde84e145800ff007b1c698a867c7196 (patch)
tree5203c02963065cba616647cc6de504e07e165691 /Completion
parent4f6a1b3717bb84b8243b13c4ec9171945893c934 (diff)
downloadzsh-6c993144bde84e145800ff007b1c698a867c7196.tar.gz
zsh-6c993144bde84e145800ff007b1c698a867c7196.tar.xz
zsh-6c993144bde84e145800ff007b1c698a867c7196.zip
51860: simplify suffix handling in _prefix to remove less accurate hack
This solves the following problems in the _prefix completer:
- The old code had logic for dealing with compstate[unambiguous] that
  was unnecessary. It works fine without it.
- Because of this logic, if a widget set compstate[insert]=1 after
  calling _main_complete, an `x` was left after the completion on the
  command line.
- If the same widget also set `compstate[to_end]=`, then instead, the
  last character of the inserted completion would be treated as an
  autoremovable suffix, with the actual suffix being inserted to the
  line as a normal character.
- After inserting a completion, the cursor would move to the end of the
  entire current word on the command, not the end of word that was
  inserted. This is not what you want with _prefix, since you are trying
  to complete a word _before_ the one on the command line, after which
  you usually want to insert a separator, such as a space or slash,
  before the next word.
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Base/Completer/_prefix9
1 files changed, 2 insertions, 7 deletions
diff --git a/Completion/Base/Completer/_prefix b/Completion/Base/Completer/_prefix
index 74be5f47d..aea2f7863 100644
--- a/Completion/Base/Completer/_prefix
+++ b/Completion/Base/Completer/_prefix
@@ -49,13 +49,8 @@ for tmp in "$comp[@]"; do
     fi
 
     if [[ "$tmp" != _prefix ]] && "$tmp"; then
-      [[ compstate[nmatches] -gt 1 ]] && return 0
-      compadd -U -i "$IPREFIX" -I "$ISUFFIX" - "${compstate[unambiguous]%$suf}x"
-      compstate[list]=
-      if [[ -n $compstate[unambiguous] ]]; then
-        compstate[insert]=unambiguous
-      else
-        compstate[insert]=0
+      if [[ -n $compstate[old_list] || ${compstate[unambiguous]%$suf} == $PREFIX ]]; then
+        compstate[to_end]=match
       fi
       return 0
     fi