Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: draw prompt on the correct line after window change



On 7/15/19, Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx> wrote:
> Many terminals reflow text when the window is resized. When the height
> of the prompt changes as a result of this reflowing, ZSH draws the
> updated prompt on the wrong line. This can lead to some parts of the
> prompt not being erased, or to the disappearance of lines prior to the
> prompt.
>
> There are many ways to reproduce this issue. Here are a couple. Both
> require terminals that reflow text when the window is resized.
>
> 1. Run `zsh -df`, hit <enter> a few times, then type
>   `xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx` (don't hit <enter>).
>
>   OR
>
> 2. Run `PROMPT="${(pl.$COLUMNS..-.)}%f"$'\n> ' zsh -df`
>   and hit <enter> a few times.
>
> Now try resizing the terminal window back and forth causing lines to
> wrap and unwrap. Terminal content before the last prompt will be
> erased one line at a time.
>
> This patch cannot handle the case when the terminal window is being
> resized while the first prompt line is outside the terminal window.
> The content of the viewport will be correct but scrolling the terminal
> window up will reveal some mess up there. ZSH before this patch also
> fails in this case although it creates a different mess.
>
> The change is conservative. The new code triggers only on window
> resize and not, for example, on redisplay. This reduces the chance
> that it'll break something that isn't currently broken.
>
> I've tested this code only on GNOME Terminal. Before I go testing on a
> dozen different terminals I'd like to get some feedback. Anything I'm
> missing? Anything tricky to look out for?

I've tested it on urxvt and it makes things worse there, enlarging the
window always deletes the last output line even with an empty input
line.

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author