jeffreytse / zsh-vi-mode

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

Two preceding line gets removed when using zsh-vi-mode with powerlevel10k inside tmux #136

Closed itsfarseen closed 1 year ago

itsfarseen commented 2 years ago

Asciinema

https://asciinema.org/a/gxwaBQ4dmYTMnJ2gNgyGH0Q0L

Steps to reproduce

Minimal repro

docker run -e TERM -e COLORTERM -e LC_ALL=C.UTF-8 -w /root -it --rm alpine sh -uexc '
  apk add curl git zsh tmux
  curl -fsSLO https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
  sh ./install.sh --unattended --skip-chsh </dev/null
  git clone --depth=1 https://github.com/jeffreytse/zsh-vi-mode.git ~/.oh-my-zsh/custom/plugins/zsh-vi-mode
  git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k
  cp ~/.oh-my-zsh/custom/themes/powerlevel10k/config/p10k-lean.zsh ~/.p10k.zsh
  sed -i.bak -E "s|POWERLEVEL9K_TRANSIENT_PROMPT=.*|POWERLEVEL9K_TRANSIENT_PROMPT=always|" ~/.p10k.zsh
  sed -i.bak -E "s|^ZSH_THEME=.*|ZSH_THEME=powerlevel10k/powerlevel10k|" ~/.zshrc
  sed -i.bak -E "s|^plugins=.*|plugins=(zsh-vi-mode)|" ~/.zshrc
  echo "source ~/.p10k.zsh" >>~/.zshrc
  echo "set -g default-command \"exec zsh\"" >>~/.tmux.conf
  exec tmux'
itsfarseen commented 2 years ago

See also https://github.com/romkatv/powerlevel10k/issues/1618#issuecomment-955651678

jeffreytse commented 2 years ago

Hi @itsfarseen

Thanks for your issue, currently I am busy, I will try to work on this issue as soon as possible.

Thanks and Regards

itsfarseen commented 2 years ago

sed -i.bak -E '/zle \.?reset-prompt/d' ~/.oh-my-zsh/custom/plugins/zsh-vi-mode/zsh-vi-mode.zsh

Removing zle reset-prompt fixes the issue and doesn't seem to break anything. Ref https://github.com/romkatv/powerlevel10k/issues/1618#issuecomment-955656371

jeffreytse commented 2 years ago

Hi @itsfarseen

Actually, it will break the vi mode indicator when user custom their prompt by the aspect. Besides, there are several places will call reset-prompt to redraw the content.

Thanks and Regards

itsfarseen commented 2 years ago

Ooh. For some reason, the current theme I use powerlevel10k, which has mode indicators, still works correctly.

image

image

I think this theme does the refresh automatically. Could you make the refresh configureable? So that when people have themes like this they can let the theme do the refresh?

jeffreytse commented 2 years ago

Hi @itsfarseen

Thanks for your information, I will take a further research on this issue, as some cases need to be reset the prompt properly (e.g. #120), and look forward to the best solution, once I got progress, I will let you know. And welcome to star this project for further update in the future.

Thanks and Regards

jeffreytse commented 2 years ago

This issue is related to #124.

troyp commented 2 years ago

The same thing happens with my custom prompt, so it probably affects all 2-line prompts

awray3 commented 2 years ago

I found that this line contains a reset prompt command that happens every time zvm_select_vi_mode() is called, which when commented out (mostly) resolved the issue of the last line getting erased in tmux for me. I don't know if this will break other things or work for other people, but it may give an idea of where this bug is coming from.

scresante commented 2 years ago

I found that this line

Thanks for the hint @awray3 . I found that removing that one line from the current master on this version of zvm somewhat helps, but spamming <esc> still results in weird behavior.

I applied your suggestion to my own fork of the project, after reverting the changes mentioned here and now things are working fine with zsh+zvm+tmux for me.