problem with multi-line prompts and vi-mode plugin #387

Closed
mgrubb opened this Issue Jun 2, 2011 · 14 comments

Comments

Projects
None yet
8 participants

mgrubb commented Jun 2, 2011

I'm a new to both zsh and oh-my-zsh. I was working with a multi-line prompt:


> '
> 
> ```
> ```

I also had the vi-mode plugin enabled.  However, when I go into command mode by pressing <Esc> it eats the last line of output from the previous command.  I've tracked the problem down to the line in the plugin file: `zle -N zle-keymap-select`
I'm using zsh version 4.3.9 (the one that ships with Mac OS X 10.6).
Contributor

giddie commented Jun 15, 2011

Yes, I think I'm seeing this too. Have you had any luck fixing this?

mgrubb commented Jun 15, 2011

Yes and no. If I don't use the vi-mode plugin and instead just use set -o vi in .zshrc that seems to do the trick. Though I'm not sure what the vi-mode plugin provides above just using set -o vi. I've also asked this question on the zsh mailing list but didn't get much in way of reply, certainly nothing that brought greater understanding on my part.

Contributor

giddie commented Jun 15, 2011

Well, it does some stuff to the theme, so that the prompt is modified when you switch into command mode. I'm not sure what the zle stuff is for. Have you tried doing a "git blame", or looking through the logs for the plugin file to see what was said about it when it was committed?

mgrubb commented Jun 15, 2011

It looks like Tomas Kramar was the original author of the plugin. Looping him into the discussion.
@kremso Tomas, could you provide any feedback about this issue?

Contributor

kremso commented Jun 17, 2011

Apart from switching the keybindings to vi, the vi-mode plugin also displays a right prompt with mode (normal/insert) indication. The bug is triggered by zle -N zle-keymap-select, because this is the code that initializes the keymap-select widget, i.e., activates the callback that is executed on each mode switch.

The callback is defined at the top of the plugin and just calls zle reset-prompt, which reevaluates and redisplays both left and right prompt. I suspect that things go wrong at this place.

I had a quick look at the reset-prompt documentation but I see no caveat there. You could try to use other method to reset the prompt, e.g. redisplay, or clear-screen, but I'm not sure it it'll work.

I've figured out the cause of this, and submitted a pull request to repair it: #597

Contributor

giddie commented Sep 12, 2011

Thank you for looking into this; this certainly seems to have improved things. Opening a new console and holding down <enter> doesn't result in the same glitches as it used to.

Contributor

giddie commented Sep 19, 2011

Hmm; I'm still seeing the bug when I resize my Konsole window. The first line of my prompt gets copied down the screen as I resize (regardless of which way I resize the window). The prompt I use is the "giddie" theme from my fork. Any ideas?

Contributor

sorin-ionescu commented Sep 25, 2011

This is a known Zsh issues that is not related to the vi-mode plugin.

@gilles gilles added a commit to gilles/oh-my-zsh that referenced this issue Dec 5, 2012

@jimhester @gilles jimhester + gilles Fixes for vi-mode terminal overwriting bugs
fixes #387 and robbyrussell#1321 (comment)
and other problems of prompt overwriting when people did not realize that it
was vi mode causing the problem.  Hat tip to sorin ionescu, as I took this code
from prezto
ba33b98

@gilles gilles added a commit to gilles/oh-my-zsh that referenced this issue Apr 5, 2013

@jimhester @gilles jimhester + gilles Fixes for vi-mode terminal overwriting bugs
fixes #387 and robbyrussell#1321 (comment)
and other problems of prompt overwriting when people did not realize that it
was vi mode causing the problem.  Hat tip to sorin ionescu, as I took this code
from prezto
f6e22b1

@w31 w31 pushed a commit to w31/oh-my-zsh that referenced this issue Apr 30, 2014

@jimhester jimhester Fixes for vi-mode terminal overwriting bugs
fixes #387 and robbyrussell#1321 (comment)
and other problems of prompt overwriting when people did not realize that it
was vi mode causing the problem.  Hat tip to sorin ionescu, as I took this code
from prezto
1862b14

@yfrancis yfrancis added a commit to yfrancis/oh-my-zsh that referenced this issue Aug 15, 2014

@jimhester @yfrancis jimhester + yfrancis Fixes for vi-mode terminal overwriting bugs
fixes #387 and robbyrussell#1321 (comment)
and other problems of prompt overwriting when people did not realize that it
was vi mode causing the problem.  Hat tip to sorin ionescu, as I took this code
from prezto
f12db80

@kenton kenton added a commit to kenton/oh-my-zsh that referenced this issue Jan 9, 2015

@jimhester @kenton jimhester + kenton Fixes for vi-mode terminal overwriting bugs
fixes #387 and robbyrussell#1321 (comment)
and other problems of prompt overwriting when people did not realize that it
was vi mode causing the problem.  Hat tip to sorin ionescu, as I took this code
from prezto
154574f

@achalddave achalddave added a commit to achalddave/dotfiles that referenced this issue Apr 20, 2015

@achalddave achalddave Fix for vim-mode + multi-line prompts
See this issue: robbyrussell/oh-my-zsh#387

Fix taken from this commit:
kenton/oh-my-zsh@154574f
158476c

This is still happening to me with my multi-line prompt setup.

This line fixed it for me, @bezhermoso. Maybe it will work for you if you are modifying zle-keymap-select or zle-line-init.

Unfortunately it doesn't fix it, @justmytwospence. I'm just using the vi-mode plugin which has that fix but still having the problem.

@justmytwospence Even an empty definition like this cause the same thing:

function zle-line-init zle-keymap-select {
  zle reset-prompt
  zle -R
}

Thoughts?

I'm honestly in over my head with this stuff, sorry.

On Tue, Oct 27, 2015 at 8:06 PM, Bez Hermoso < notifications@github.com [notifications@github.com] > wrote:
@justmytwospence [https://github.com/justmytwospence] Even an empty definition like this cause the same thing:

function zle-line-init zle-keymap-select {
zle reset-prompt
zle -R
}

Thoughts?


Reply to this email directly or view it on GitHub
[https://github.com/robbyrussell/oh-my-zsh/issues/387#issuecomment-151707788] .[https://github.com/notifications/beacon/ACr-lk0c8nGkPUuq3chKMbK6zZzITQUDks5pADM_gaJpZM4AS2es.gif]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment