jeffreytse / zsh-vi-mode

💻 A better and friendly vi(vim) mode plugin for ZSH.
MIT License
2.93k stars 102 forks source link

Inserting completions erases prompt #237

Open musjj opened 11 months ago

musjj commented 11 months ago

General information

Please report the following information as possible as you can:

Basic examination

Problem description

When trying to perform a completion, the prompt is sometimes erased. If the candidate is long enough, the completion result itself is truncated (only visually).

I think there has been a regression somewhere, because I remember that it was working just fine a few weeks ago.

rec

Reproduction steps

  1. Activate a prompt e.g. starship-rs
  2. Try to complete something long

Expected behavior

Prompt doesn't disappear

musjj commented 10 months ago

I bisected, and found the commit where this issue starts happening: 6f14b2f6a00e03004abe5fa5ca95c7f4d8875348

b-m-f commented 10 months ago

I am experiencing the same issue when using fzf for history search

luong-komorebi commented 10 months ago

Seeing the same issue when using fzf for history search and control T completion. Autocompletion is not affected

@b-m-f a quick fix would be: you press escape (or literally take zsh-vi-mode to visual) and then escape again (bring it back to insert), the error would be gone and you would use fzf as normal (no prompt is cleared)

jhthorsen commented 10 months ago

I had the same experience with fzf, but I managed to find a workaround:

function dotfiles_fzf_history_widget() {
  fzf-history-widget "$@";
  zle .reset-prompt; # This is the workaround
}

zvm_define_widget dotfiles_fzf_history_widget;
zvm_bindkey viins '^R' dotfiles_fzf_history_widget;

So the fix is that I call .reset-prompt, which is the default reset-prompt, instead of zsh-vi-mode's zvm_reset_prompt. I've tried to add "echo" to that widget to see what happens, and for some reason it seems like $ZVM_POSTPONE_RESET_PROMPT is set to "1". I haven't looked into it further, since I'm ok with the current workaround.

Anvesh9652 commented 3 months ago

@jhthorsen, thank you for the workaround. It got fixed for CTRL + R, And this issue exists for CTRL + T and for ** Tab (complete) too. If you have any solutions for these, can you please post them here?

jhthorsen commented 3 months ago

Unfortunately not. I changed back to bash after having too many old servers that didn't have recent enough zsh for me to work efficiently.