Closed yshui closed 2 years ago
Can you please use the setup below (which was in the bug report template, but you deleted it) to create a minimal, reproducible test case? Then I'll reopen your issue.
cd $(mktemp -d)
git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
> .zshrc <<EOF
PS1='%# ' PS2= RPS2='%^'; setopt transientrprompt interactivecomments
source ~/zsh-autocomplete/zsh-autocomplete.plugin.zsh
EOF
env -i HOME=$PWD PATH=$PATH TERM=$TERM ${TERMINFO:+TERMINFO=$TERMINFO} zsh -d
@marlonrichert it happens with this .zshrc:
PS1='%# ' PS2= RPS2='%^'; setopt transientrprompt interactivecomments
zstyle ':autocomplete:tab' insert-unambiguous 'yes'
source ~/zsh-autocomplete/zsh-autocomplete.plugin.zsh
@yshui Please turn it into a test case that has all the steps I need to reproduce the problem. Simply running the code you now pasted does not reproduce the problem.
So:
Expected:
The longest common prefix is inserted.
Actual:
The first result is inserted.
some files
Please be more specific than that. Update your test case so that I can copy-paste it into my terminal and run it.
Read this for more help on what to do: https://stackoverflow.com/help/minimal-reproducible-example
some files
literally any files. like:
mkdir files
cd files
touch aaa aab aac
and Tab gives me aaa
instead of aa
In that scenario, do you press Tab on an empty line? Or what is left of your cursor when you press Tab?
Or what is left of your cursor when you press Tab?
A command that accepts a file, like ls
Thanks, I can reproduce it now. Will fix.
@yshui You're missing a colon. It should be
zstyle ':autocomplete:tab:*' insert-unambiguous yes
or just
zstyle ':autocomplete:*' insert-unambiguous yes
thanks. That fixed it in the MRE environment, but in my actual environment it still doesn't work.
ah, i see. so the behavior is to insert the common prefix if there is one. if the candidates don't have a common prefix, then the first choice is inserted. I was expecting it to insert nothing, as the common prefix would be an empty string.
Do you think that's what most people using insert-unambiguous
would want? I don't use it myself, so it's hard for me to judge.
If it worked like that, wouldn't you then be unable to insert anything else than the common prefix? I mean, how would you then insert any completion that's not exactly equal to the common prefix? Would you always use the arrow keys? Or would you just type until you have only one completion left and then press Tab?
Other people could chime in, but IMO tab and arrow key would fit well with these two different kinds of completions - Tab to insert common prefix, and arrow key to select from the menu. I think another option would be using the "tab, tab again" behavior, i.e. tab once to insert common prefix, if the user tapped tab again immediately, enter selection. I think most of the users would be used to this behavior?
I think most of the users would be used to this behavior?
Probably, but the autocompletion makes it a bit trickier. I’ll look into. Pull requests welcome, too, of course. 🙂
Actually, it might already work out of the box like that, if you also add this (before sourcing the plugin):
zstyle ':autocomplete:*' widget-style menu-complete
Can you try that out?
Tested again and I can't reproduce it.
Failure to do so can and will result in your issue being closed without warning.
Environment
Steps to reproduce
I'm using
zimfw
, my.zshrc
:my
.zimrc
:Pressing
TAB
always insert the first entry in the list, despiteinsert-unambiguous yes