Zsh-autosuggestions: Suggestions not cleared after enter

Created on 18 Apr 2020  Â·  6Comments  Â·  Source: zsh-users/zsh-autosuggestions

Describe the bug

Suggestions not cleared after enter

Expected behavior

Clearing autosuggestions after enter

Screenshots

Peek 2020-04-18 12-08

Desktop

image

  • OS: Arch Linux 2020.04.18
  • Zsh version: 5.8
  • Plugin version: latest

Additional context

These options do not help solve this problem.
ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(expand-or-complete bracketed-paste accept-line push-line-or-edit)

bug

Most helpful comment

I found out that my conflict came from oh-my-zsh plugin magic-enter: https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/magic-enter/magic-enter.plugin.zsh#L24

For now I have disabled magic-enter. Maybe I will remap it to a different key. not sure.

All 6 comments

I also have the same problem which kept me from really using this addon. otherwise I love it.

A bit more background:

  • I'm using archlinux on the hardened kernel (but also hat it on the normal kernel)
  • I use antigen to handle zsh plugins

I also have this issue. However I'm not sure it's a bug in zsh-autosuggestions.

I cannot reproduce this with zsh-autosuggestions installed alone, with zgen, over a fresh/vanilla zsh :

gawa@localhost:~> git clone https://github.com/tarjoilija/zgen.git "${HOME}/.zgen"
Cloning into '/home/gawa/.zgen'...
[...]
gawa@localhost:~> source "${HOME}/.zgen/zgen.zsh"
gawa@localhost:~> zgen load zsh-users/zsh-autosuggestions
Cloning into '/home/gawa/.zgen/zsh-users/zsh-autosuggestions-master'...
[...]
gawa@localhost:~> pwd
/home/gawa
gawa@localhost:~> cd /mnt
gawa@localhost:/mnt> #   ^-- it suggested "/mnt/storage" but the "/storage" dissapeard after pressing enter, as expected. No bug.
gawa@localhost:/mnt>

It looks like the bug is introduced by my prompt :

gawa@localhost:/mnt> zgen load subnixr/minimal
Cloning into '/home/gawa/.zgen/subnixr/minimal-master'...
[...]
λ › cd /mnt                                                                                                                                  /mnt
λ › #   ^--- here I already was in /mnt, as shown in the right prompt. I only typed "/" and pressed enter. The suggestion didn't clear.                                                                                                    /
λ › pwd                                                                                                                                          /
/
λ ›  

The good news is that since subnixr/minimal is a minimal prompt, it'll be easier to debug.

In my case it was a conflict with the prompt subnixr/minimal. The last thing it does is remapping the enter key with bindkey -M main "^M" buffer-empty

My workaround consists in overriding this in my .zshrc after loading the prompt, I want the return key to be mapped to the default "accept-line" : bindkey -M main "^M" accept-line

It does the trick. Alternatively, after identifying the zle widget called by the return key (^M), you could add it in the autosuggest option. In my case ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(buffer-empty) works. However I really didn't understand what is this buffer-empty widget, since it doesn't even seem to exists in zsh and my prompt really.

That said, I found another bug : pressing ctrl+c doesn"t clear the suggestion. I didn't find a workaround for that.

I found out that my conflict came from oh-my-zsh plugin magic-enter: https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/magic-enter/magic-enter.plugin.zsh#L24

For now I have disabled magic-enter. Maybe I will remap it to a different key. not sure.

I found out that my conflict came from oh-my-zsh plugin magic-enter: https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/magic-enter/magic-enter.plugin.zsh#L24

For now I have disabled magic-enter. Maybe I will remap it to a different key. not sure.

Really thanks for this. I couldn't find out it was the one conflicting.

I found out that my conflict came from oh-my-zsh plugin magic-enter: https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/magic-enter/magic-enter.plugin.zsh#L24

For now I have disabled magic-enter. Maybe I will remap it to a different key. not sure.

Thanks! It`s solved my problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OmeGak picture OmeGak  Â·  3Comments

raulferras picture raulferras  Â·  3Comments

dragonxlwang picture dragonxlwang  Â·  3Comments

sebw picture sebw  Â·  6Comments

NikKovIos picture NikKovIos  Â·  4Comments