marlonrichert / zsh-autocomplete

🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.
MIT License
5.27k stars 146 forks source link

Unexpected matching order of dotfiles but not regular files #444

Closed sameaton closed 2 years ago

sameaton commented 2 years ago

When autocompleting files starting with a . the first matches appear to be fuzzy rather than exact matches:

Environment

apple darwin21.0 /bin/zsh zsh zsh-5.8.1-0-g1a490c7
/Users/same/.antidote/functions/antidote-load:21
/Users/same/.antidote/functions/_antidote_main:23
/Users/same/.antidote/functions/antidote:48
/Users/same/.zshrc:72
5b0073d (grafted, HEAD -> main, origin/main, origin/HEAD) Check that `$ZSH_COMPDUMP` file can be read

Steps to reproduce

cd $(mktemp -d)
git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
Cloning into 'zsh-autocomplete'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (55/55), done.
remote: Total 59 (delta 0), reused 27 (delta 0), pack-reused 0
Receiving objects: 100% (59/59), 1.64 MiB | 6.69 MiB/s, done.
> .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
% ls -a
.           .cache          .fzf.zsh        .local          .zshrc          foo.thing       thing.foo
..          .foo            .lesshst        .zhistory       foo         foo2            zsh-autocomplete

% ls foo
file
foo        foo.thing  foo2
all matches
foo foo.thing foo2

% ls .z
file
.fzf.zsh   .zhistory  .zshrc
all matches
.fzf.zsh .zhistory .zshrc

As per the above shell session, when completing regular filenames, exact prefixes match first as you'd expect, but in the second example when I'm trying to autocomplete dotfiles, when starting with .z I get autosuggestions with .fzf.zsh as the first match rather than with .zhistory as the first match like I'd expect and like I get with regular files

marlonrichert commented 2 years ago

This is intentional. When you type .thing, Autocomplete will match *.thing*, so you can easily get a list of all *.thing files even when there are .thing* files present.