Subject: Re: unwanted scrolling of the terminal
From: Bart Schaefer <[email-masked]>
To: Zsh workers <[email-masked]>
Date: Thu, 23 Jun 2016 16:30:54 -0700
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Thu, Jun 23, 2016 at 5:19 AM, Peter Stephenson
<[email-masked]> wrote:
> On Thu, 23 Jun 2016 13:58:51 +0200
> Oliver Kiddle <[email-masked]> wrote:
>>
>> So why the two spaces? The second of those is what caused the scrolling.
>
> It appears to be specific to terminals with automatic margins (hasam).

Yes, that would be it.

> I *think* that code is supposed to have the effect of ensuring if we
> subsequently [move] the cursor right without printing then it knows that
> the new line is actually a logical continuation of the previous one ---
> hence the subsequent carriage return to get back from there.

I think it's actually trying to make sure there's room to print the
buffer without having the terminal scroll during printing; ZLE has to
make sure that the location corresponding to CURSOR=0 won't change
while the buffer is being output, and the easiest way to do that is to
force any change that might happen to happen first.  But I'm surmising
from insufficient knowledge, same as you.

It's also possible that this is a vi-mode-specific problem though it
doesn't sound like it from Oliver's description of code walk-through.

The only person who might remember how all this came together is Wayne.

> This code is all originally 1990s --- I have no idea if modern terminals
> even respond to these tricks.  I think automatic margin problems were
> much more trendy twenty years ago.

Certainly there were more terminals that handled it wrong back then,
but it wasn't that long ago that we had to introduce
ZLE_RPROMPT_INDENT to address a related issue.