Discarded autosuggestions are not cleared when using bhilburn/powerlevel9k theme #162

Open
PiQuer opened this Issue May 28, 2016 · 9 comments

4 participants

@PiQuer

If an autosuggestion appears but I choose to ignore it and press enter to execute everything up to the cursor (without the autosuggested part), the autosuggestion is still displayed as part of the command line, even though greyed out. For example:

$ echo "Hello World" "Bye"
$ echo "Hello World"

yields:
screenshot_20160528_110822
I find this is confusing when looking back over the commands, as the actually executed commands do not always match the displayed command line. It is especially confusing for someone else watching you type.

Maybe this is intended behaviour, but I would love to have a configuration switch which tells zsh-autosuggestions to clear everything to the right of the cursor, once enter is pressed.

@ericfreese
zsh-users member

Interesting. Trying this myself, it looks like the suggestion is cleared for me. So I'm not sure what's going on here. Can you give some more details on your system?

What OS?
What version of zsh?
What version of this plugin?

@ericfreese
zsh-users member

One more question: Can you reproduce this without loading any other configuration? Try zsh -f and sourcing the plugin manually.

@PiQuer

Ok, it is my theme: bhilburn/powerlevel9k. As soon as this theme is activated, the problem occurs.
To reproduce:

$ zsh -f
$ source /path/to/powerlevel9k/powerlevel9k.zsh-theme
$ source /path/to/zsh-autosuggestions/zsh-autosuggestions.zsh
$ echo "Hello, World" "Bye"
$ echo "Hello, World"

Arch Linux, zsh-5.2, zsh-autosuggestions-0.3.1

@ericfreese
zsh-users member

Ok, thanks for looking deeper into this. This issue will probably be low priority for me, since I only have so much time to work on this project and I don't use that theme.

If you can figure out a change that fixes your problem without any consequences for other users, I'll be happy to merge it in. Just send a PR to merge into the develop branch.

@ericfreese ericfreese changed the title from Discarded autosuggestions are not cleared from commandline to Discarded autosuggestions are not cleared when using bhilburn/powerlevel9k theme Jun 9, 2016
@PiQuer

Thanks Eric. Probably I will also have no time for debugging any time soon, but who knows ;) If I find something I will send a PR.

@PiQuer PiQuer referenced this issue in bhilburn/powerlevel9k Jun 22, 2016
Open

incompatibility with autosuggestion plugin #281

@retnuh

I have pretty much the exact same problem, but it's not about my theme - I have a very simple rebinding of accept-line to reset my prompt first:

reset-prompt-and-accept-line() {
  zle reset-prompt
  zle accept-line
}
zle -N reset-prompt-and-accept-line
bindkey "^M" reset-prompt-and-accept-line

I've tried putting unset POSTDISPLAY pretty much everywhere to no avail, and calls to zle -R -c, and I can see it disappear but it then re-appears.

I'm no zsh wizard so I'm not really clear how this all works. I may throw in a recursiveedit call to see if that helps but it's more of a guess than anything.

@retnuh

FWIW I was able to solve the problem by adding

ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=reset-prompt-and-accept-line

to my snippit where I create & bind my widget.

There may be a similar widget being used in the OPs theme that could easily be added, or maybe the theme itself uses reset-prompt or something similar, and that should be in the default list of clear widgets?

@marudor

For me this fixed it with powerlevel9k

ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=reset-prompt
@PiQuer

Thanks for this fix, it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment