marlonrichert / zsh-autocomplete

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

zsh-autocomplete prevents zoxide's popup from exiting #739

Open artuross opened 4 months ago

artuross commented 4 months ago

Description

I use zinit for loading plugins and zoxide as a cd replacement. When I type z dir <tab>, zoxide shows a popup to select directory. However, if I decide to cancel (either with ESC or ctrl + c), the popup reopens with "0n" typed to search. This happens consistently 3 times, after which canceling works as expected. The same issue occurs on each new zoxide invocation.

Please check this screencast with zsh-autocomplete:

asciicast

And without, for comparison:

asciicast

The only difference between these two in environment is line 24 in .zshrc (loading of zsh-autocomplete).

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=(
  /Users/artur/.local/share/zinit/plugins/marlonrichert---zsh-autocomplete/zsh-autocomplete.plugin.zsh:4
  /opt/homebrew/opt/zinit/zinit.zsh:1833
  /opt/homebrew/opt/zinit/zinit.zsh:1700
  /opt/homebrew/opt/zinit/zinit.zsh:1338
  /opt/homebrew/opt/zinit/zinit.zsh:2831
  /Users/artur/.zshrc:24
  zsh:0
)

% git -C ~autocomplete log --oneline -n1
cfc3fd9 (HEAD -> main, origin/main, origin/HEAD) Fix grammar mistakes in Readme

Steps to reproduce

This is my .zshrc. I've verified that commenting out loading zsh-autocomplete and restarting terminal would fix the issue. Everything (zoxide, zinit, zsh-autocomplete) is on latest version.

# ##################################################
# zinit setup
# ##################################################
if [[ ! -f "/opt/homebrew/opt/zinit/zinit.zsh" ]]; then
    echo 'zinit not installed.'
    echo 'Check https://github.com/zdharma-continuum/zinit#automatic'
    return
fi

source "/opt/homebrew/opt/zinit/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit

# ##################################################
# plugins
# ##################################################
zinit ice lucid wait'0'

zinit light atuinsh/atuin
zinit light marlonrichert/zsh-autocomplete
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-syntax-highlighting
zinit snippet OMZP::dotenv

autoload -Uz compinit && compinit
zmodload -i zsh/complist
rm -f ~/.zcompdump; compinit
autoload -U +X compinit && compinit
autoload -U +X bashcompinit && bashcompinit

# ##################################################
# nice tools
# ##################################################
eval "$(zoxide init zsh)"
eval "$(starship init zsh)"
jake-klingler commented 3 months ago

I've noticed the exact same behavior, and tracked it down to zsh-autocomplete. Commenting out zsh-autocomplete makes this issue go away. When this happens, it also leaves a zombie zsh process running with 100% cpu usage in the background.

Meegooo commented 3 weeks ago

When this happens, it also leaves a zombie zsh process running with 100% cpu usage in the background.

I found that doing removing completions for zoxide via compdef -d z stops zombie zsh process from spawning. This obviously breaks the interactive menu, but since I don't use it, it works for me.

This implies that zombie process seems to spawn because of a compatibility issue between zoxide's compdef and zsh-autocomplete. I think a better workaround would be to stop zsh-autocomplete from doing its suggestions when command starts with z<space>, but I haven't found a way to do so.

PS. For me the popups worked as expected, it's only the zombie process that was the problem. Plugins were loaded in following order zsh-autocomplete, fzf, zoxide. But the zombie process made it impossible to use.