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

Bug with zsh-syntax-highlighting: unhandled ZLE widget #711

Open ForsakenRei opened 6 months ago

ForsakenRei commented 6 months ago

Environment

% typeset -p1 VENDOR OSTYPE ZSH_PATCHLEVEL _autocomplete__funcfiletrace

typeset -p1 VENDOR OSTYPE ZSH_PATCHLEVEL _autocompletefuncfiletrace typeset VENDOR=redhat typeset OSTYPE=linux-gnu typeset ZSH_PATCHLEVEL=zsh-5.8-0-g77d203f typeset -a _autocompletefuncfiletrace=( /home/shigure/.zsh/zsh-autocomplete/zsh-autocomplete.plugin.zsh:4 .zshrc:44 zsh:1 )

% git -C ~autocomplete log --oneline -n1

d408d90 (HEAD) Remove erroneous break statement

This is a working commit from Mar 25th I'm using on a different system, tried latest head 1968100 and another commit b62154d but the problem persists.

Steps to reproduce

git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
git clone https://github.com/marlonrichert/zsh-autocomplete.git ~/.zsh/zsh-autocomplete
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.zsh/zsh-syntax-highlighting

Content of my .zshrc, just kept those 3 lines to isolate the issue while I'm testing.

# zsh plugins
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
source ~/.zsh/zsh-autocomplete/zsh-autocomplete.plugin.zsh
source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

After source, output

zsh-syntax-highlighting: unhandled ZLE widget 'insert-unambiguous-or-complete' zsh-syntax-highlighting: (This is sometimes caused by doing bindkey <keys> insert-unambiguous-or-complete without creating the 'insert-unambiguous-or-complete' widget with zle -N or zle -C.) zsh-syntax-highlighting: unhandled ZLE widget 'menu-search' zsh-syntax-highlighting: (This is sometimes caused by doing bindkey <keys> menu-search without creating the 'menu-search' widget with zle -N or zle -C.) zsh-syntax-highlighting: unhandled ZLE widget 'recent-paths' zsh-syntax-highlighting: (This is sometimes caused by doing bindkey <keys> recent-paths without creating the 'recent-paths' widget with zle -N or zle -C.)

originally I thought it's syntax highlighting but checking with

echo $widgets[insert-unambiguous-or-complete]
echo $widgets[recent-paths]
echo $widgets[menu-search]

I got those output

completion:complete-word:.autocompletecomplete-wordcompletion-widget user:.autocomplete:async:toggle-context completion:menu-select:.autocompletecomplete-wordcompletion-widget

If I remove auto-complete then everything works fine.

Contents of ~autocomplete-log/YYYY-MM-DD.log (click to expand)

Nathanjp91 commented 6 months ago

Same issue here. Also thought it was syntax-highlighting as that's the error output, but went through my list of plugins turning them off one by one and it stopped when autocomplete was turned off but syntax-highlighting was still on.

Angluca commented 5 months ago
zsh-syntax-highlighting: unhandled ZLE widget 'menu-search'
zsh-syntax-highlighting: unhandled ZLE widget 'insert-unambiguous-or-complete'
zsh-syntax-highlighting: unhandled ZLE widget 'recent-paths'
# ------------ log
_complete:6: command not found: _autocomplete__recent_paths
_complete:7: command not found: _autocomplete__ancestor_dirs
autocomplete:_main_complete:new:post:3: command not found: _autocomplete__unambiguous
autocomplete:_main_complete:new:post:3: command not found: _autocomplete__unambiguous

# If you dont like popup them, you can commit 3 line, The world is quiet now.

# zsh-autocomplete/Functions/Init/.autocomplete__key-bindings
#line 49-50:
#"$backtab" insert-unambiguous-or-complete
#'^X/' recent-paths
#line 57:
#${0}:bind                         menu-search history-incremental-search-forward  '^S' '?'
moutazhaq commented 5 months ago

I'm having the same issue.

I've narrowed it down to commit 545051e44407ac42215495d283c37cea9f8be362.

Before this commit, the functions rebind() and bound() were being called for 'menu-search', etc., and the call to bound() would return false preventing the bindkey command in rebind() from executing.

After this commit, the bindkey command is executed for all the bindings without any check. For some reason this then causes zsh-syntax-highlighting to complain about these bindings.

Renan-Olovics commented 2 months ago

same issue here

image
johnnymatthews commented 1 month ago

For folks encountering this error who don't care about using an old-ish version of this repo, follow these steps as a quick hack to get things working. These steps assume you've already followed the installation instructions from the README.md in this repo.

  1. Delete your current copy of zsh-autocomplete:

    rm ~/.config/zsh/zsh-autocomplete
  2. Re-clone this repo, but this time with all the history intact:

    git clone https://github.com/marlonrichert/zsh-autocomplete ~/.config/zsh/zsh-autocomplete
  3. Move into that new directory and checkout to commit 8f54aabb5eee3a317ef6ea9c94d4714ae669329e, the commit just before the offending commit found by @moutazhaq:

    cd ~/.config/zsh/zsh-autocomplete
    git checkout 8f54aabb5eee3a317ef6ea9c94d4714ae669329e
  4. Reload your shell. You shouldn't see any errors anymore.

Again, by following these steps, you'll miss out on updates to this repo since April 2024.