jeffreytse/zsh-vi-mode

Inserting completions erases prompt

musjj opened this issue · 6 comments

musjj commented

General information

Please report the following information as possible as you can:

  • Terminal program: kitty 0.29.2
  • Operating system: NixOS 23.05
  • ZSH framework: zgenom
  • ZSH version: 5.9

Basic examination

  • I have read through the README page
  • I have the latest version of zsh-vi-mode
  • I have tested with another terminal program

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

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

b-m-f commented

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

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)

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.

@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?

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.