zsh-autosuggestions
zsh-autosuggestions copied to clipboard
ZSH_AUTOSUGGEST_CLEAR_WIDGETS is neutral after startup
Describe the bug
I need three widgets in the CLEAR_WIDGETS set. I thought that I'll add them in a simple snippet:
if (( ${+ZSH_AUTOSUGGEST_CLEAR_WIDGETS} )); then
ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=( ziactioncomplete
ziactioncompleteice ziactioncompleteinsert )
ZSH_AUTOSUGGEST_CLEAR_WIDGETS=(
${(@u)ZSH_AUTOSUGGEST_CLEAR_WIDGETS}
)
fi
however, such widgets are ignored by autosuggestions – the problem with leaked value for $LASTWIDGET occurs – it's set to autosuggest-suggest wrongly interrupting my widgets cooperation, which basically resembles copy-earlier-word – detects consecutive sequences of operation via [[ $WIDGET == $LASTWIDGET ]] comparison.
Expected behavior
The widgets should be ignored/protected by zsh-autosuggestions. And they are if I add the widgets to the zsh-autosuggestions.zsh file directly to the array.
I've did print the ZSH_AUTOSUGGEST_CLEAR_WIDGETS array to ensure that the modifications applied.
Desktop
- OS + distribution:
- Zsh version: 5.8
- Plugin version: a411ef3e
Additional context
I've could create some work arounds but they are no where as effective as zsh-autosuggestions setup to protect my widgets. The project works so flawlessly then!
Please allow registering widgets in zsh-autosuggestions so that plugins can cooperate.
Do you perhaps have automatic rebinding disabled via ZSH_AUTOSUGGEST_MANUAL_REBIND? If so, you'll need to call _zsh_autosuggest_bind_widgets yourself after modifying the widget lists such as ZSH_AUTOSUGGEST_CLEAR_WIDGETS.
Modifying the widget lists after the plugin is instantiated is supported by default. You should be able to add a widget to the clear list and see that it clears the suggestion when invoked.
% zsh -df
ericfreese% noop() {}
ericfreese% zle -N noop
ericfreese% bindkey ^A noop
ericfreese% source zsh-autosuggestions.zsh
ericfreese% ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(noop)
With this setup, if I press s, it will suggest source zsh-autosuggestions.zsh. When I press ^A it clears the suggestion and shows just the s.
But with ZSH_AUTOSUGGEST_MANUAL_REBIND enabled as below, ^A does nothing when the suggestion is shown.
% zsh -df
ericfreese% noop() {}
ericfreese% zle -N noop
ericfreese% bindkey ^A noop
ericfreese% source zsh-autosuggestions.zsh
ericfreese% ZSH_AUTOSUGGEST_MANUAL_REBIND=on
ericfreese% ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(noop)
Though after rebinding the widgets, I do get the desired behavior:
ericfreese% _zsh_autosuggest_bind_widgets