zsh-autosuggestions
zsh-autosuggestions copied to clipboard
Suggestion not cleared on bindable completion commands
Describe the bug
If a suggestion is present, using the completion widgets _most_recent_file, _history-complete-newer and _history-complete-older does not clear the suggestion, even when the widgets are present in ZSH_AUTOSUGGEST_CLEAR_WIDGETS.
To Reproduce
Steps to reproduce the behavior:
% zsh -df
% source path/to/zsh-autosuggestions.zsh
% autoload compinit && compinit # Load completion widgets
% source path/to # then hit Alt+/ to execute _history-complete-older
Expected behavior
The suggestion should have be cleared when the history word is inserted.
Desktop
- OS + distribution: Arch Linux 2020.03.01
- Zsh version: 5.8
- Plugin version: 0.6.4
Additional context
The mentioned completion widgets are documented in zshcompsys(1) under 'Bindable Commands', and are added when running compinit.
It seems that these widgets are not wrapped by zsh-autosuggestions:
% zle -l | grep _history-complete
_history-complete-newer -C .complete-word _history_complete_word
_history-complete-older -C .complete-word _history_complete_word
Thanks for this. I think I copied the widget binding code from zsh-syntax-highlighting long ago which originally included the omission of widgets that start with _ but has since been changed. I think we can apply the same change here: https://github.com/zsh-users/zsh-syntax-highlighting/commit/ed33d2cb13884b298a996ceadfc94ae6ffd78825
https://github.com/zsh-users/zsh-autosuggestions/blob/ae315ded4dba10685dbbafbfa2ff3c1aefeb490d/src/bind.zsh#L71
I've applied the patch locally to zsh-autosuggestions.zsh, however this doesn't fix the problem for me. The suggestion is still shown after a history word was inserted.
However, it seems that the widgets are now wrapped correctly?
Before:
% zle -l | grep _history-complete
_history-complete-newer -C .complete-word _history_complete_word
_history-complete-older -C .complete-word _history_complete_word
After:
% zle -l | grep _history-complete
_history-complete-newer (_zsh_autosuggest_bound_1__history-complete-newer)
_history-complete-older (_zsh_autosuggest_bound_1__history-complete-older)
autosuggest-orig-1-_history-complete-newer -C .complete-word _history_complete_word
autosuggest-orig-1-_history-complete-older -C .complete-word _history_complete_word