Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1466683132; bh=Er2FEf6rXYJevMQcrNEA90WTwvFEwn0Mtg3AhXKg2j8=; h=From:To:Subject:Date:From:Subject; b=CXI2Aj6nzckqgUvQUpbRdkmvpVFrPOOamCJWL4mO80KSjirAw5bsjxAf/dE4rvuIbhKZwvwFxr063MRIpVzzDao7NFzUZ5lBU0v7ob8XCLDGUIw0aN0aD0BkHMkN3/rveoHeQj24EuK9RQ/b3c6oTdXRpz+tAfsvH5y0sSwn1r9DNYYR5Ad+PTcSyQjJpWTGBPb09lE/Z2wjqO9rGqFpXWf88qxqajq5jX2YaX5Faocy4nriTzkoMcvJToFLjknt5OTlo3Mbr4RQqQXHqGdYtW+SdtmnYizpbwWqq8uNZyAMUOVDvKh2UydnyVWFn+6wxisU/6gSpPxGT7ClA81z+w==
X-Yahoo-Newman-Id: 519974.18426.bm@smtp145.mail.ir2.yahoo.com
X-Yahoo-Newman-Property: ymail-3
X-YMail-OSG: BHpZliIVM1k9Ky8_MzX2iaPIKaLcqlVsUKRVTUee7O7uECg
 VB5kBfv0BA4XLmAOY6FVCkIt2kBKm8gW8I92Dd6uBbwvU9kzvNvU9lMEYxvs
 HmiT8yhSyVsCFXA9eNypqVpcqDh8rL3IZYzkx38zl.r6buB930G40BoJFxcq
 Qs_YmmqpERqaVOo5zK5ynBCBBbuXt_MobNg8bYSZairoYa29FZy0xRopRdlk
 DTmL_Wi.19gks7_x0olPSAd.BpaeUn6V6_dHB64ZWn79kQjMsnWZE9QQb.eP
 eRv7u9ulW1HNx6zTSIds_mMAdkJcrKc27YSp9R4dzjFh4iU1dnS5hIcaQ6gS
 VYvFcoIZjVp4Z4KzjnelqK.pBHafvEqTN4uFFkYvj_iNmSrSRZ5K3V7heVzC
 9yO.8XHefU2frkpKhnRFNRcb3tMir3dJpgVzrvNGFh_E1ZN_odvozsBsSNtm
 bJB8V8tHFiZuEKYAQaDH3jipGqIIcAX5FX8nes7SY9OwrdmzoLdjNqO1VFUt
 RFq2ntymDZbtZpxt_UxUgdAUjYO5UiA--
X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI-
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh workers <zsh-workers@zsh.org>
Subject: unwanted scrolling of the terminal
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <30659.1466683131.1@thecus.kiddle.eu>
Date: Thu, 23 Jun 2016 13:58:51 +0200
Message-ID: <30660.1466683131@thecus.kiddle.eu>
X-Seq: zsh-workers 38754

I think there may be a bug somewhere in the zle_refresh code which is
resulting in the terminal scrolling up when it shouldn't. This occurs
with urxvt but I think the key thing in that is that $termcap[ic] is
available rather than urxvt itself.

To reproduce it from zsh -f with urxvt, the following setup is needed.
You also need to make sure that the prompt is at the bottom of the
terminal.
zle-keymap-select() {
  zle reset-prompt
}
zle -N zle-keymap-select
zle_highlight=( 'default:fg=black' )
bindkey -v

Then enter: [escape]ox[escape]>k

That will indent the x but it also scrolls giving the impression that an
additional line has been added at the bottom. I would suspect that there
are other ways to trigger the same set of conditions that cause this
and there isn't much that is special about the particular widgets used
here. It is hard to verify with old versions of zsh because vi-indent
was broken before. Note that there is no right prompt and no real need
for zsh to be putting anything near the end of the line.

Looking at the output in a script log for an 84 char width terminal, I get:
  x
  \e[39m  - colour
  \e[K    - clear to eol
  \r
  \e[8@   - insert 8 characters
  \e[34m
  eight spaces
  \e[75C  - cursor right 75 chars
  \e[39m
  two spaces
  \r

So why the two spaces? The second of those is what caused the scrolling.
The first one is printed from line 1958 in zle_refresh.c
The second is from line 2175 in the moveto function

At this point, I'm fairly stuck on how this might be fixed. It isn't at
all clear to me what moveto is doing printing stuff anyway unless it is
to intentionally cause scrolling. zle_refresh.c is mostly fairly good on
comments but that part lacks any. The main substance of that code seems
to have been around as long as the version control but it has also been
changed so maybe someone knows what it is supposed to be doing? Is vcs
zero or one-based indexing of the cursor position. Given the former,
vcs == winw would mean it has already printed something in the final
column.

Oliver

