jeffreytse/zsh-vi-mode

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

MonstrousOgre opened this issue ยท 10 comments

General information

  • Terminal program: iterm2 3.4.19
  • Operating system: macOS Ventura 13.4.1
  • ZSH framework: zsh-syntax-highlighting 0.7.1
  • ZSH version: 5.9
  • ZVM version: 0.10.0

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 (I used the default macOS terminal)

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.

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

Untitled.mov

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

@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)"

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.

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.

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.

Related to #124

Hi @MonstrousOgre,

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

Thanks & Regards

Thanks! It's working fine