Zsh-autosuggestions: Interaction with completion menu

Created on 15 Feb 2016  路  3Comments  路  Source: zsh-users/zsh-autosuggestions

When it inserts the current choice from the completion menu, the grey autosuggest sticks around and changes to the normal color. See https://asciinema.org/a/ateiyie18acvm3l7srfezt89g for a screencast of the behavior. bindkey '^I' is expand-or-complete.

bug has-workaround reproduced

Most helpful comment

This is what I was referring to as "minor issues with the buffer displaying incorrectly while inside menu selection" in this comment, but I never created a separate issue for the problem.

Using menu selection is what causes this issue. I believe this is the minimal .zshrc config to reproduce this problem:

autoload compinit && compinit
zstyle ':completion:*' menu select
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

I haven't yet found a way to bind to a menu selection event to clear/update the suggestion. Probably will need to dig into this document to find a solution.

As far as I know, there are two options to workaround this issue temporarily:

  1. Don't use menu selection. Remove the zstyle line above or set the menu style to no-select with zstyle ':completion:*' menu no-select. This will keep suggestions working while doing completions.
  2. Add your bound completion widget(s) (expand-or-complete in your case) to the list of widgets that clear the suggestion. This will have the effect of disabling suggestions while you're in menu selection, but at least it won't leave a lingering, broken suggestion. Add ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=("expand-or-complete") somewhere in your .zshrc after sourcing this plugin.

We may want to add expand-or-complete to ZSH_AUTOSUGGEST_CLEAR_WIDGETS by default, but I believe that would break suggestions for folks not using menu selection, so I think this belongs in individual user configuration for now.

All 3 comments

This is what I was referring to as "minor issues with the buffer displaying incorrectly while inside menu selection" in this comment, but I never created a separate issue for the problem.

Using menu selection is what causes this issue. I believe this is the minimal .zshrc config to reproduce this problem:

autoload compinit && compinit
zstyle ':completion:*' menu select
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

I haven't yet found a way to bind to a menu selection event to clear/update the suggestion. Probably will need to dig into this document to find a solution.

As far as I know, there are two options to workaround this issue temporarily:

  1. Don't use menu selection. Remove the zstyle line above or set the menu style to no-select with zstyle ':completion:*' menu no-select. This will keep suggestions working while doing completions.
  2. Add your bound completion widget(s) (expand-or-complete in your case) to the list of widgets that clear the suggestion. This will have the effect of disabling suggestions while you're in menu selection, but at least it won't leave a lingering, broken suggestion. Add ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=("expand-or-complete") somewhere in your .zshrc after sourcing this plugin.

We may want to add expand-or-complete to ZSH_AUTOSUGGEST_CLEAR_WIDGETS by default, but I believe that would break suggestions for folks not using menu selection, so I think this belongs in individual user configuration for now.

Ah! Thanks for the detailed and quick response, much appreciated.

This should be fixed in v0.3.2 (just released) by commit e87bc74

Was this page helpful?
0 / 5 - 0 ratings

Related issues

raulferras picture raulferras  路  3Comments

OmeGak picture OmeGak  路  3Comments

clay-f picture clay-f  路  7Comments

guitaristtom picture guitaristtom  路  6Comments

dragonxlwang picture dragonxlwang  路  3Comments