jeffreytse / zsh-vi-mode

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

Switching between insert and normal mode clears the previous line on macOS #234

Closed MonstrousOgre closed 10 months ago

MonstrousOgre commented 11 months ago

General information

Basic examination

Problem description

When I have both ZVM and starship prompt enabled, switching between normal and insert mode clears the line above. It doesn't happen when I have only ZVM or only starship enabled. Also doesn't happen when I use starship with just bindkey -v. This also seems to be happening only on my mac. I can't reproduce this on my desktop which has Arch Linux. I have zvm installed using homebrew.

Reproduction steps

  1. Install ZVM and enable it.
  2. Install Starship prompt and enable it.
  3. Try to switch between insert and normal mode.

Expected behavior

It should switch between modes without clearing anything.

MonstrousOgre commented 11 months ago

The behavior I'm experiencing is the similar to #181

MonstrousOgre commented 11 months ago

https://github.com/jeffreytse/zsh-vi-mode/assets/16362557/f3c21309-9a0c-4747-a3d5-fa98d6b36f63

jeffreytse commented 11 months ago

Hi @MonstrousOgre,

Thanks for your reporting, could you explore a minimum .zshrc for me to dig the issue further? I'd love to help you settle down this issue.

Thanks & Regards

MonstrousOgre commented 11 months ago

@jeffreytse thanks for your response! I tried what you asked and narrowed it down to these 3 lines that are causing the problem. Removing any one of them fixes it, but then I lose some features.

source $HOMEBREW_PREFIX/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source $(brew --prefix)/opt/zsh-vi-mode/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
eval "$(starship init zsh)"
MonstrousOgre commented 11 months ago

Update: The reason it wasn't happening on my Arch machine is because the AUR package was on version 0.9.0. I just tried the zsh-vi-mode-git package and now it's happening even on Arch.

Looks like a problem with a recent commit.

MonstrousOgre commented 11 months ago

So I ended up doing a git bisect to see which commit started the issue. This is what I ended up with

db7b7d45e969cc1cee879e7c4ba8fb20aa539314 is the first bad commit
commit db7b7d45e969cc1cee879e7c4ba8fb20aa539314
Author: Jeffrey Tse <jeffreytse.mail@gmail.com>
Date:   Sun Jul 9 21:54:22 2023 +0800

    fix: zsh-syntax-highlighting was broken (#228)

    This issue was caused by a bug which didn't invoke original function
    after hooking the function. This bug also caused issues mentioned in
    the #154 as well.

 zsh-vi-mode.zsh | 1 +
 1 file changed, 1 insertion(+)

Looks like fixing the zsh-syntax-highlighting caused some other issue. My issue is only happening if zsh-syntax-highlighting, zsh-vi-mode, and starship are all enabled together.

MonstrousOgre commented 11 months ago

So this problem is happening because both pacman and homebrew have zsh-syntax-highlighting in version 0.7.1. Using version 0.8.0 fixes the problem, but it's still in alpha. For now I just cloned their repo and I'm using that.

jeffreytse commented 11 months ago

Related to #124

jeffreytse commented 11 months ago

Hi @MonstrousOgre,

Thanks for your reporting, I've addressed the root cause and fixed it.

Thanks & Regards

MonstrousOgre commented 11 months ago

Thanks! It's working fine