From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: zsh-workers@zsh.org
Subject: Incorrect cursor position when ZLE_RPROMPT_INDENT=0 (with a fix)
Date: Sun, 19 May 2019 17:38:16 +0200 [thread overview]
Message-ID: <CAN=4vMpx_B5TRNQzDAvBoTFszoKea2=uQr5xjd0vZVH6py+oVA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 3170 bytes --]
To reproduce:
ZLE_RPROMPT_INDENT=0
PROMPT=12
RPROMPT=3
Expected behavior: The cursor is positioned after ‘2’.
Actual behavior: The cursor is positioned on ‘2’.
The following patch fixes this issue.
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 1f293845f..9c650d3ae 100644--- a/Src/Zle/zle_refresh.c+++
b/Src/Zle/zle_refresh.c
@@ -1678,7 +1678,7 @@ zrefresh(void)
moveto(0, winw - rprompt_off - rpromptw);
zputs(rpromptbuf, shout);- vcs = winw - rprompt_off;+
vcs = winw - (rprompt_off ? rprompt_off : 1);
/* reset character attributes to that set by the main prompt */
txtchange = pmpt_attr;
/*
@@ -2159,7 +2159,7 @@ moveto(int ln, int cl)
const REFRESH_ELEMENT *rep;
if (vcs == winw) {- if (rprompt_indent == 0 && tccan(TCLEFT))
{+ if (0) {
tc_leftcurs(1);
vcs--;
} else {
There is now an if-else with 0 as the condition. I’ve posted the diff this
way to make it clearer what I’d actually changed. The if-else can, of
course, be replaced with a single block of code (what used to be under else),
which produces a larger diff due to indentation changes. ZSH source code
uses a mixture of tabs and spaces, so I’m not sure if I deindented it right.
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 1f293845f..85f9d9305 100644--- a/Src/Zle/zle_refresh.c+++
b/Src/Zle/zle_refresh.c
@@ -1678,7 +1678,7 @@ zrefresh(void)
moveto(0, winw - rprompt_off - rpromptw);
zputs(rpromptbuf, shout);- vcs = winw - rprompt_off;+
vcs = winw - (rprompt_off ? rprompt_off : 1);
/* reset character attributes to that set by the main prompt */
txtchange = pmpt_attr;
/*
@@ -2159,25 +2159,20 @@ moveto(int ln, int cl)
const REFRESH_ELEMENT *rep;
if (vcs == winw) {- if (rprompt_indent == 0 && tccan(TCLEFT))
{- tc_leftcurs(1);- vcs--;- } else {- vln++, vcs =
0;- if (!hasam) {- zputc(&zr_cr);-
zputc(&zr_nl);- } else {- if ((vln < nlnct) && nbuf[vln]
&& nbuf[vln]->chr)- rep = nbuf[vln];- else-
rep = &zr_sp;- zputc(rep);- zputc(&zr_cr);- if
((vln < olnct) && obuf[vln] && obuf[vln]->chr)- *obuf[vln]
= *rep;- }- }+ vln++, vcs = 0;+ if (!hasam) {+
zputc(&zr_cr);+ zputc(&zr_nl);+ } else {+ if ((vln < nlnct)
&& nbuf[vln] && nbuf[vln]->chr)+ rep = nbuf[vln];+ else+
rep = &zr_sp;+ zputc(rep);+ zputc(&zr_cr);+ if ((vln <
olnct) && obuf[vln] && obuf[vln]->chr)+ *obuf[vln] = *rep;+
}
}
if (ln == vln && cl == vcs)
The same thing on github:
https://github.com/zsh-users/zsh/compare/master…romkatv:rprompt-indent
<https://github.com/zsh-users/zsh/compare/master...romkatv:rprompt-indent>.
I’ve verified that it works correctly with ZLE_RPROMPT_INDENT={0,1,2} in
GNOME Terminal on Ubuntu 18.04. The cursor gets positioned in the right
place and there is no weird behavior in completion menu or other multi-line
ZLE situations.
Roman.
next reply other threads:[~2019-05-19 15:39 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-19 15:38 Roman Perepelitsa [this message]
2019-05-19 15:41 ` Roman Perepelitsa
2019-05-19 17:04 ` Bart Schaefer
2019-05-19 17:34 ` Roman Perepelitsa
2019-05-19 18:09 ` Roman Perepelitsa
2019-05-19 18:51 ` Roman Perepelitsa
2019-05-19 20:12 ` Bart Schaefer
2019-05-19 21:07 ` Roman Perepelitsa
2019-05-20 8:21 ` Yannic Schröder
2019-05-20 8:36 ` Roman Perepelitsa
2019-05-20 10:21 ` Charles Blake
2019-05-20 10:46 ` Roman Perepelitsa
2019-05-20 11:06 ` Daniel Shahaf
2019-05-20 11:07 ` Charles Blake
2019-05-20 11:11 ` Peter Stephenson
2019-05-20 11:32 ` Roman Perepelitsa
2019-05-20 12:41 ` Charles Blake
2019-05-20 13:16 ` Roman Perepelitsa
[not found] ` <CAKiz1a-nOkAe42JoxFRgMJ+LXZ3fgMxqgwNZOW+2Y45oqzu8hA@mail.gmail.com>
2019-05-20 13:55 ` Roman Perepelitsa
2019-05-23 5:48 ` Roman Perepelitsa
2019-05-23 21:36 ` Daniel Shahaf
2019-05-23 22:52 ` Roman Perepelitsa
2019-05-24 12:18 ` Daniel Shahaf
2019-05-27 15:36 ` Roman Perepelitsa
2019-05-27 21:51 ` Peter Stephenson
2019-05-28 8:44 ` Peter Stephenson
2019-05-28 8:46 ` Roman Perepelitsa
2019-05-28 14:26 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAN=4vMpx_B5TRNQzDAvBoTFszoKea2=uQr5xjd0vZVH6py+oVA@mail.gmail.com' \
--to=roman.perepelitsa@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).