zsh-users / zsh-autosuggestions

Fish-like autosuggestions for zsh
MIT License
30.95k stars 1.86k forks source link

Missing character for long suggestions #578

Closed AckslD closed 3 years ago

AckslD commented 3 years ago

Describe the bug

When a autosuggestion is longer than the terminal width and the current text stop matching the long suggestion, one character is no longer displayed in the terminal. I think the easiest is to explain with the screencast below:

To Reproduce

Steps to reproduce the behavior:

Expected behavior

No missing characters.

Screenshots

zsh_autosuggestions_issue

Note, that the second command works, it's just that the " is not displayed when typing the command.

Desktop

Additional context

I'm using the following plugins.

plugins=(
    git
    virtualenv
    zsh-autosuggestions
    zsh-syntax-highlighting
    zsh-vim-mode
    timer
    tmux
    history-substring-search
    archlinux
)
ericfreese commented 3 years ago

Hi, I'm not able to reproduce this. I'm guessing that it has something to do with your prompt. Can you reproduce with a simpler prompt?

AckslD commented 3 years ago

Hi @ericfreese thanks for you suggestion. I will play around with some simpler prompts to see if I can find out what's going on.

AckslD commented 3 years ago

@ericfreese I think I narrowed it down to how I make the prompt different depending on whether the last command succeeded or not. I'm able to reproduce the issue with this minimal prompt:

PROMPT='%{%(?.v.x)%}: '

Any idea if this is an issue with autosuggestions or with the way I'm doing it?

ericfreese commented 3 years ago

I'm not an expert on prompt expansion, but it looks like you might be using %{...%} incorrectly.

http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Visual-effects

It says

The string within the braces should not change the cursor position.

But your string within the braces does change the cursor position by outputting either v or x.

Can you remove the use of that construct and just do this?

PROMPT='%(?.v.x): '
AckslD commented 3 years ago

Thanks a lot @ericfreese! This solved it for me :) I wasn't really sure what exactly %{...%} was doing since I just edited the existing muse theme. Anyway I replaced most of them with %F..%f around coloured parts and the issue is gone.