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

Bug + patch: _expand() fails to insert unambiguous prefix



Test case:
```
cd $(mktemp -d)
exec zsh -f
autoload -Uz compinit; compinit
zstyle ':completion:*' completer _expand _complete
zstyle ':completion:*' tag-order '! original all-expansions'
zstyle ':completion:*' show-ambiguity yes
bindkey '^I' complete-word
touch bar baz
file ^I
file *^I
```

Patch:
```
diff --git Completion/Base/Core/_main_complete
Completion/Base/Core/_main_complete
index 663f755..ec2d954 100644
--- Completion/Base/Core/_main_complete
+++ Completion/Base/Core/_main_complete
@@ -248,11 +248,10 @@ if [[ $compstate[old_list] = keep || nm -gt 1 ]]; then
         ( -n "$_menu_style[(r)select=long-list]" ||
           -n "$_menu_style[(r)(yes|true|on|1)=long-list]" ) ]]; then
     compstate[insert]=menu
-  elif [[ "$compstate[insert]" = "$_saved_insert" ]]; then
-    if [[ -n "$compstate[insert]" &&
+  elif [[ -n "$compstate[insert]" &&
       -n "$_menu_style[(r)(yes|true|1|on)=long]" && tmp -gt LINES ]]; then
     compstate[insert]=menu
-    else
+  elif [[ -n "$_saved_insert" && -n "$compstate[insert]" ]]; then
       sel=( "${(@M)_menu_style:#(yes|true|1|on)*}" )

     if (( $#sel )); then
@@ -291,15 +290,18 @@ if [[ $compstate[old_list] = keep || nm -gt 1 ]]; then
     fi
     if [[ ( -n "$min" && nm -ge min && ( -z "$max" || nm -lt max ) ) ||
           ( -n "$_menu_style[(r)auto*]" &&
-              "$compstate[insert]" = automenu ) ]]; then
+              "$_saved_insert" = automenu ) ]]; then
       compstate[insert]=menu
     elif [[ -n "$max" && nm -ge max ]]; then
       compstate[insert]=unambiguous
     elif [[ -n "$_menu_style[(r)auto*]" &&
-              "$compstate[insert]" != automenu ]]; then
+              "$_saved_insert" != automenu ||
+            "$PREFIX$SUFFIX" != *"$compstate[unambiguous]"* ]]; then
       compstate[insert]=automenu-unambiguous
+    elif [[ -z "$compstate[old_list]" ]]; then
+      compstate[insert]=
     fi
-    fi
+    compstate[list]="${compstate[list]/ambiguous/list}"
   fi

   if [[ "$compstate[insert]" = *menu* ]]; then
```




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