-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zle autosuggest-clear
and _zsh_autosuggest_clear
not clearing suggestions when called from a widget
#716
Comments
It looks like you have a small typo
Does that fix it? |
Thanks for the quick response! Good catch but that typo was in the issue writeup only. Also missed creating the keymap. And the example could be more minimal, I've found the— intended steps? bug workaround?: add my widget to # setup
% zsh -df
% source path/to/zsh-autosuggestions.zsh
% my_widget() {}
% typeset -ga ZSH_AUTOSUGGEST_IGNORE_WIDGETS # new
% ZSH_AUTOSUGGEST_IGNORE_WIDGETS+=(my_widget) # new
% zle -N my_widget
% bindkey '^[[B' my_widget # bind to down arrow
# zle autosuggest-clear example
% my_widget() { zle autosuggest-clear }
% s # `source path/to/zsh-autosuggestions.zsh` is suggested
# down arrow clears the suggestion
# _zsh_autosuggest_clear example
% my_widget() { _zsh_autosuggest_clear }
% s # `source path/to/zsh-autosuggestions.zsh` is suggested
# down arrow clears the suggestion My own need is cleared up. Still seems like either a bug or something missing from the documentation. The README doesn't suggest that adding to Happy to PR a clarification to https://github.com/zsh-users/zsh-autosuggestions#key-bindings if that'd be helpful. |
I had time, so opened a PR with the expectation that you might simply close it. |
One thing maybe worth noting is that the intended way to use those provided If you want a custom widget to clear a suggestion rather than have a suggestion fetched after it runs, you should actually add it to ❯ zsh -df
ericfreese% source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
ericfreese% my_widget() {}
ericfreese% zle -N my_widget
ericfreese% bindkey '^[[B' my_widget
ericfreese% ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(my_widget)
ericfreese% s # pressing down arrow clears the suggestion There's some additional documentation about that here: https://github.com/zsh-users/zsh-autosuggestions#widget-mapping |
Aha! Missed that. Thank you. edit oh look at that, sorry for the noise. I'm not sure I've ever referenced a GitHub issue in a commit message body, didn't know it would generate activity. |
Describe the bug
I can't clear suggestions from custom widgets.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Widgets can clear suggestions.
Screenshots
Desktop
Additional context
The text was updated successfully, but these errors were encountered: