zsh-autosuggestions icon indicating copy to clipboard operation
zsh-autosuggestions copied to clipboard

Suggestion not cleared on bindable completion commands

Open sgleizes opened this issue 5 years ago • 2 comments

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

sgleizes avatar May 09 '20 13:05 sgleizes

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

ericfreese avatar May 18 '20 14:05 ericfreese

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

0xC0FFEE avatar Jun 22 '21 10:06 0xC0FFEE