marlonrichert / zsh-autocomplete

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

Available completions not shown for commands with slow `compdef` functions #713

Open ethantkoenig opened 7 months ago

ethantkoenig commented 7 months ago

Environment

% typeset -p1 VENDOR OSTYPE ZSH_PATCHLEVEL _autocomplete__funcfiletrace
typeset VENDOR=apple
typeset OSTYPE=darwin23.0
typeset ZSH_PATCHLEVEL=zsh-5.9-0-g73d3173
typeset -a _autocomplete__funcfiletrace=(
  /var/folders/wn/hb12b9pd7vvcghywcg1npbgh0000gp/T/tmp.SOEDKKuKg2/zsh-autocomplete/zsh-autocomplete.plugin.zsh:4
  /var/folders/wn/hb12b9pd7vvcghywcg1npbgh0000gp/T/tmp.SOEDKKuKg2/.zshrc:5
  zsh:0
)
% git -C ~autocomplete log --oneline -n1
1968100 (grafted, HEAD -> main, origin/main, origin/HEAD) Fix bugs in `recent-paths` widget

Steps to reproduce

% cd $(mktemp -d)
% git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
<output>
% > .zshrc <<EOF
setopt interactivecomments transientrprompt
PS1='%# '
PS2=
RPS2='%^'
source $PWD/zsh-autocomplete/zsh-autocomplete.plugin.zsh
EOF
% env -i HOME=$PWD PATH=$PATH TERM=$TERM ${TERMINFO:+TERMINFO=$TERMINFO} zsh -d
% _fast_foo() { local -a subcmds; subcmds=('a:1' 'b:2'); _describe 'command' subcmds }
% _slow_foo() { sleep 1; _fast_foo }
% compdef _fast_foo fast_foo
% compdef _slow_foo slow_foo
% fast_foo  # <-- available completions are displayed after typing space past "fast_foo"
command
a  -- 1
b  -- 2
% slow_foo  # <-- available completions are not displayed

Verified that ~autocomplete-log/2024-04-08.log is empty (after running the above commands):

% ls -s ~autocomplete-log/2024-04-08.log
0 /var/folders/wn/hb12b9pd7vvcghywcg1npbgh0000gp/T/tmp.SOEDKKuKg2/.local/state/zsh-autocomplete/log/2024-04-08.log