zsh-users
 help / Atom feed
* zle .redisplay sometimes eating up a line
@ 2019-07-15  3:02 Sebastian Gniazdowski
  2019-07-15  9:18 ` Roman Perepelitsa
  2019-07-29 19:13 ` Sebastian Gniazdowski
  0 siblings, 2 replies; 9+ messages in thread
From: Sebastian Gniazdowski @ 2019-07-15  3:02 UTC (permalink / raw)
  To: Zsh Users

Hello,
I have a problem where a .redisplay call done from a zle -F callback
eats up a previous line of text in the terminal. There it happens with
100% accuracy, always. When trying to reproduce it happens
occasionally, as recorded in the following video:

https://asciinema.org/a/257379

(it's using function:
https://gist.github.com/psprint/f2a0db07cc80351e19e30378c6eaa779)

I wonder what might be the cause? I recall that there are messages
appearing on a regular basis on a prompt eating up the last line of
the display. Maybe the issues are related?

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: zle .redisplay sometimes eating up a line
  2019-07-15  3:02 zle .redisplay sometimes eating up a line Sebastian Gniazdowski
@ 2019-07-15  9:18 ` Roman Perepelitsa
  2019-07-15 18:31   ` Sebastian Gniazdowski
  2019-07-29 19:13 ` Sebastian Gniazdowski
  1 sibling, 1 reply; 9+ messages in thread
From: Roman Perepelitsa @ 2019-07-15  9:18 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh Users

On Mon, Jul 15, 2019 at 5:03 AM Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> Hello,
> I have a problem where a .redisplay call done from a zle -F callback
> eats up a previous line of text in the terminal.

What's your $ZSH_PATCHLEVEL?

Could you post self-contained instructions for reproducing this?
Something like this:

1. Start `zsh -df`.
2. Copy-paste this code. The code should not require Internet access.
3. Press and hold Ctrl+T.

Roman.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: zle .redisplay sometimes eating up a line
  2019-07-15  9:18 ` Roman Perepelitsa
@ 2019-07-15 18:31   ` Sebastian Gniazdowski
  2019-07-15 18:43     ` Roman Perepelitsa
  0 siblings, 1 reply; 9+ messages in thread
From: Sebastian Gniazdowski @ 2019-07-15 18:31 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Zsh Users

On Mon, 15 Jul 2019 at 11:18, Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
> What's your $ZSH_PATCHLEVEL?

zsh-5.7.1-101-g09385d3

> Could you post self-contained instructions for reproducing this?
> Something like this:
>
> 1. Start `zsh -df`.
> 2. Copy-paste this code. The code should not require Internet access.
> 3. Press and hold Ctrl+T.
>
> Roman.

The instructions will be not fully self-contained, as the issue
reveals itself with 3 plugins being loaded:

1. git clone https://github.com/geometry-zsh/geometry
2. git clone https://github.com/zsh-users/zsh-autosuggestions autos
3. git clone https://github.com/zsh-users/zsh-syntax-highlighting zsyh
4. zsh -dfi
5. source geometry/geometry.plugin.zsh
6. source autos/zsh-autosuggestions.zsh
7. source zsyh/zsh-syntax-highlighting.zsh
8. Paste the code (http://sprunge.us/SAkQxz):
deploy-code() {
[[ "$1" = <-> && ${#} -eq 1 ]] && {
    local alltext text IFS=$'\n' nl=$'\n'
     repeat 25; do read -r -u"$1" text; alltext+="${text:+$text$nl}"; done
    zle -F "$1"; exec {1}<&-
    eval "$alltext"
    return 0
}
local THEFD
exec {THEFD} < <(
    # The expansion is: if there is @sleep: pfx, then use what is after
    # it, otherwise substitute 0
    LANG=C sleep $(( 0.005 + ${${${(M)1#@sleep:}:+${1#@sleep:}}:-0} ))
    print -r -- ${1:#(@code|@sleep:*)} "${@[2,-1]}"
)
zle -N deploy-code
zle -w -F "$THEFD" deploy-code
}
deploy-code-widget() { BUFFER+='B'; deploy-code @sleep:0.5
"BUFFER+='a'; zle .redisplay;"; }
zle -N deploy-code-widget
bindkey "^T" deploy-code-widget

9. Press and long hold Ctrl-T

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: zle .redisplay sometimes eating up a line
  2019-07-15 18:31   ` Sebastian Gniazdowski
@ 2019-07-15 18:43     ` Roman Perepelitsa
  2019-07-15 18:53       ` Sebastian Gniazdowski
  0 siblings, 1 reply; 9+ messages in thread
From: Roman Perepelitsa @ 2019-07-15 18:43 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh Users

On Mon, Jul 15, 2019 at 8:31 PM Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
> > What's your $ZSH_PATCHLEVEL?
>
> zsh-5.7.1-101-g09385d3

Good. This rules out a few bugs fixed recently that affect lprompth.

> > Could you post self-contained instructions for reproducing this?
>
> The instructions will be not fully self-contained, as the issue
> reveals itself with 3 plugins being loaded:
>
> [...]

This is too much. The first thing anyone trying to debug this will
have to do is reduce the number of steps that are necessary to
reproduce this bug. If you do it, it makes it that much more likely
someone will care enough to fix the bug.

Since the prompt overflow bugs have been ruled out, the next most
common reason for the prompt to be redisplayed on the previous line is
when `redisplay` is called after a prior prompt change that wasn't
followed by `zle -R`. Here's a simple example:

1. Run `zsh -df`.

2. Paste this:

    function reset() { zle .reset-prompt; zle .redisplay }
    zle -N reset
    bindkey '^T' reset
    PROMPT=$'\n> '

3. Press Ctrl-T. Observe that prompt moves one line up.

The fix is to call `zle -R` before `zle .redisplay`.

I'm not saying this is the culprit of your problem but it might be.
It's hard to tell when the setup for reproducing it requires thousands
of lines of ZSH scripts.

Roman.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: zle .redisplay sometimes eating up a line
  2019-07-15 18:43     ` Roman Perepelitsa
@ 2019-07-15 18:53       ` Sebastian Gniazdowski
  2019-07-16 22:12         ` Sebastian Gniazdowski
  0 siblings, 1 reply; 9+ messages in thread
From: Sebastian Gniazdowski @ 2019-07-15 18:53 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Zsh Users

On Mon, 15 Jul 2019 at 20:44, Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
> Since the prompt overflow bugs have been ruled out, the next most
> common reason for the prompt to be redisplayed on the previous line is
> when `redisplay` is called after a prior prompt change that wasn't
> followed by `zle -R`. Here's a simple example:
>
> 1. Run `zsh -df`.
>
> 2. Paste this:
>
>     function reset() { zle .reset-prompt; zle .redisplay }
>     zle -N reset
>     bindkey '^T' reset
>     PROMPT=$'\n> '
>
> 3. Press Ctrl-T. Observe that prompt moves one line up.
>
> The fix is to call `zle -R` before `zle .redisplay`.

BIG thanks! Adding zle -R before .redisplay call fixed my original
problem, and also the demonstration-sample.

> I'm not saying this is the culprit of your problem but it might be.
> It's hard to tell when the setup for reproducing it requires thousands
> of lines of ZSH scripts.

It was difficult to narrow down the issue as it was hidden somewhere
in the scripts.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: zle .redisplay sometimes eating up a line
  2019-07-15 18:53       ` Sebastian Gniazdowski
@ 2019-07-16 22:12         ` Sebastian Gniazdowski
  0 siblings, 0 replies; 9+ messages in thread
From: Sebastian Gniazdowski @ 2019-07-16 22:12 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Zsh Users

On Mon, 15 Jul 2019 at 20:53, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
> > The fix is to call `zle -R` before `zle .redisplay`.
>
> BIG thanks! Adding zle -R before .redisplay call fixed my original
> problem, and also the demonstration-sample.

Turns out that, as the documentation of zle -R suggests, also
replacing zle .redisplay with zle -R works. I wonder what's the
difference between those two calls?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: zle .redisplay sometimes eating up a line
  2019-07-15  3:02 zle .redisplay sometimes eating up a line Sebastian Gniazdowski
  2019-07-15  9:18 ` Roman Perepelitsa
@ 2019-07-29 19:13 ` Sebastian Gniazdowski
  2019-07-29 21:46   ` Mikael Magnusson
  1 sibling, 1 reply; 9+ messages in thread
From: Sebastian Gniazdowski @ 2019-07-29 19:13 UTC (permalink / raw)
  To: Zsh Users

On Mon, 15 Jul 2019 at 05:02, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
> Hello,
> (it's using function:
> https://gist.github.com/psprint/f2a0db07cc80351e19e30378c6eaa779)

I've noticed an interesting use case for the function – running zle
widgets without a keybindings – a natural, expected way to do it (at
least at initial contact with Zsh):

autoload tetriscurses
zle -N tetriscurses
deploy-code "zle tetriscurses"

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: zle .redisplay sometimes eating up a line
  2019-07-29 19:13 ` Sebastian Gniazdowski
@ 2019-07-29 21:46   ` Mikael Magnusson
  2019-07-29 22:16     ` Sebastian Gniazdowski
  0 siblings, 1 reply; 9+ messages in thread
From: Mikael Magnusson @ 2019-07-29 21:46 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh Users

On 7/29/19, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> On Mon, 15 Jul 2019 at 05:02, Sebastian Gniazdowski
> <sgniazdowski@gmail.com> wrote:
>> Hello,
>> (it's using function:
>> https://gist.github.com/psprint/f2a0db07cc80351e19e30378c6eaa779)
>
> I've noticed an interesting use case for the function – running zle
> widgets without a keybindings – a natural, expected way to do it (at
> least at initial contact with Zsh):
>
> autoload tetriscurses
> zle -N tetriscurses
> deploy-code "zle tetriscurses"

tetriscurses isn't a zle widget.

-- 
Mikael Magnusson

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: zle .redisplay sometimes eating up a line
  2019-07-29 21:46   ` Mikael Magnusson
@ 2019-07-29 22:16     ` Sebastian Gniazdowski
  0 siblings, 0 replies; 9+ messages in thread
From: Sebastian Gniazdowski @ 2019-07-29 22:16 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Zsh Users

On Mon, 29 Jul 2019 at 23:46, Mikael Magnusson <mikachu@gmail.com> wrote:
> > I've noticed an interesting use case for the function – running zle
> > widgets without a keybindings – a natural, expected way to do it (at
> > least at initial contact with Zsh):
> >
> > autoload tetriscurses
> > zle -N tetriscurses
> > deploy-code "zle tetriscurses"
>
> tetriscurses isn't a zle widget.

true, but tetris works :)


-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-15  3:02 zle .redisplay sometimes eating up a line Sebastian Gniazdowski
2019-07-15  9:18 ` Roman Perepelitsa
2019-07-15 18:31   ` Sebastian Gniazdowski
2019-07-15 18:43     ` Roman Perepelitsa
2019-07-15 18:53       ` Sebastian Gniazdowski
2019-07-16 22:12         ` Sebastian Gniazdowski
2019-07-29 19:13 ` Sebastian Gniazdowski
2019-07-29 21:46   ` Mikael Magnusson
2019-07-29 22:16     ` Sebastian Gniazdowski

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox