Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Incorrect cursor position when ZLE_RPROMPT_INDENT=0 (with a fix)
- X-seq: zsh-workers 44321
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Incorrect cursor position when ZLE_RPROMPT_INDENT=0 (with a fix)
- Date: Sun, 19 May 2019 17:41:53 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=nQ3XZUWv1Abqr+dd8rhaVBAUAaAKcMe+2NrtrNtV07U=; b=t/mT9gIrXzsdhYSa3kPRcGNLr8+ZCDqfIYsTzWGC9wRkofi4PyQ8HgmQMIU8ioNhMm g+Yz0QG9LDbhvTulIMEduc5PLbxoyQhW2EjL+N0b5y0wnFvOeZpsZxiOF+vlRsU+JQvt jhpKItrRHD3buuBaQavBCg5YWENoib/4CIOTLatmqBQT7xUAj09vMlKgmMO9cSDbb4n+ Rz4AAcUrA90EyBnlbC4CHP6Lyq24yILIMiP6cDUFfg+IlGn8uatKKO70rbGZkgg95dbm ZYLfNzL1rTVAElUxliQVBx7aApfDjPZ7ttUlbzMvqPL8nr1wfTVKoMAK6LtlAKsilAQ8 MhNA==
- In-reply-to: <CAN=4vMpx_B5TRNQzDAvBoTFszoKea2=uQr5xjd0vZVH6py+oVA@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAN=4vMpx_B5TRNQzDAvBoTFszoKea2=uQr5xjd0vZVH6py+oVA@mail.gmail.com>
In case the patch got mangled by the mail server, please see
https://github.com/zsh-users/zsh/compare/master...romkatv:rprompt-indent.
Roman.
On Sun, May 19, 2019 at 5:38 PM Roman Perepelitsa <
roman.perepelitsa@xxxxxxxxx> wrote:
> 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.
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author