zsh-workers
 help / color / mirror / code / Atom feed
From: Marlon Richert <marlon.richert@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Bug + patch: _expand() fails to insert unambiguous prefix
Date: Thu, 4 Mar 2021 21:49:47 +0200	[thread overview]
Message-ID: <CAHLkEDt3=NKioi4GJkzyTnGGVZb_cV+ibBsd+eDPp99VZ3ZDVA@mail.gmail.com> (raw)

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
```


             reply	other threads:[~2021-03-04 19:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-04 19:49 Marlon Richert [this message]
2021-03-20  1:50 ` Lawrence Velázquez
2021-03-20 11:20   ` Marlon Richert
2021-03-20 14:42     ` Lawrence Velázquez
2021-03-20 18:22       ` Marlon Richert
2021-03-20 20:54       ` Oliver Kiddle
2021-03-21  9:49         ` Marlon Richert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHLkEDt3=NKioi4GJkzyTnGGVZb_cV+ibBsd+eDPp99VZ3ZDVA@mail.gmail.com' \
    --to=marlon.richert@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).