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

Prompt jumps up a line on certain actions #42

Open
ecbaldwin opened this issue Sep 8, 2021 · 4 comments
Open

Prompt jumps up a line on certain actions #42

ecbaldwin opened this issue Sep 8, 2021 · 4 comments

Comments

@ecbaldwin
Copy link

ecbaldwin commented Sep 8, 2021

I think I've seen this with a few different actions but the one that I know is repeatable is when I type 'S' in command mode. The following sequence does it for me reliably.

  1. Either open a new terminal or just hit to get a fresh prompt.
  2. Type <esc>S

At this time, the prompt jumps up deleting whatever line came before it. In my case, I use a two-line prompt, and both lines in the prompt jump up to delete the line of output before them.

To illustrate, I open up a new terminal and echo some output. At this point, my terminal looks like this:

Last login: Wed Sep  8 14:38:23 on ttys004
╭─ ~                                                                      ✔
╰─ echo "output to be clobbered by the next prompt"
output to be clobbered by the next prompt
╭─ ~                                                                      ✔
╰─

Then, I hit <esc>S and my terminal looks like this:

Last login: Wed Sep  8 14:38:23 on ttys004
╭─ ~                                                                       ✔
╰─ echo "output to be clobbered by the next prompt"
╭─ ~                                                                       ✔
╰─

Notice that the line of output following the echo got eaten and my prompt is now one line higher in the terminal than it started at.

This is something I run into all the time because I often start typing a command, realize that I needed to run something different first, and I hit <esc>S to start over. Occasionally, some output that was important is clobbered by this bug.

@ecbaldwin
Copy link
Author

As I was playing with this and writing the initial description, I realized that if I hit <esc>S repeatedly, it will eat all of the lines in the terminal until the prompt gets to the top of the screen.

@softmoth
Copy link
Owner

softmoth commented Dec 2, 2021

I think maybe this only happens with multi-line prompts. I'll try to narrow it down. I was able to reproduce it with the standard prompt fade.

A quick workaround is to disable the automatic tweaking of the prompt by setting MODE_INDICATOR= before you load zsh-vimi-mode:

MODE_INDICATOR=
source ~/path/to/zsh-vim-mode/zsh-vim-mode.plugin.zsh

I will see if I can find out what is causing this problem, but hopefully that workaround will help in the mean time.

@softmoth
Copy link
Owner

softmoth commented Dec 3, 2021

This appears to be a Zsh bug. I narrowed it down to this minimal .zshrc:

autoload -Uz promptinit; promptinit
prompt redhat

PS1='%!
%# '

autoload -Uz add-zle-hook-widget

test-zle-reset-hook () { zle reset-prompt; }

add-zle-hook-widget line-pre-redraw test-zle-reset-hook

I was not able to get it to happen with a plain PS1 without first using prompt redhat (or any other promptinit prompt). I'm not yet sure if this is a bug in promptinit, zle's line-pre-redraw hook, or if I'm using something incorrectly.

@ecbaldwin
Copy link
Author

The MODE_INDICATOR= work-around seems to be working just fine for me. I do not find the mode indicator useful and so I was not making use of it anyway. Thanks!

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