From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id dbabd232 for ; Sun, 19 May 2019 15:39:22 +0000 (UTC) Received: (qmail 23322 invoked by alias); 19 May 2019 15:39:04 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44320 Received: (qmail 20830 invoked by uid 1010); 19 May 2019 15:39:04 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f48.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25447. spamassassin: 3.4.2. Clear:RC:0(209.85.166.48):SA:0(-2.3/5.0):. Processed in 1.51002 secs); 19 May 2019 15:39:04 -0000 X-Envelope-From: roman.perepelitsa@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.48 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=jJg9L8rFzfYqPwzAH7D2Ar8Bk4ezZcrIReKqI+izbMI=; b=ID5fjEp/8P7HNorokXgT9gh3NrONG9AJJuWwb5Q0XxD+xUo1+bhOlMqoWOghYb4/lv OH0OwmtUSN+F5wy9lSPVUZRUHpc3HbQgMo7Ci+DKEO512yahcAaONUwL7u0dqc5j68w6 TQHxGRKXTM6TnjGmUcT5lC93BiOA1LiZNP9HScmuDDhehAVbEhTFjHPGQ/kFZa/0mSZw ZJomE1IIIwsa5H1w3bPBwxJQqUOynZxeJ4Q1zn3sleH3R0RcCpyJyRDc7O9IYiWBEb0S nPaKRTT2ZJ3Gy/9GCBa5lyJKniLTD9nCCUBbDefHazzSvHADG4rbZ19hLN/b1XxkFMzl A08Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=jJg9L8rFzfYqPwzAH7D2Ar8Bk4ezZcrIReKqI+izbMI=; b=QPQqRmw4ZSe29C8R4+xt1+fY74PGVfovV6BuPe64E67xBSi5N/5OskJ9GgTUtWtyji wiX30P+0hXxveTQR5cgTughHL3rZBS0Thg8k0+0/fKC8NLxmjM8/LKGEWRSQ3+XDiOAx 1hDmYeFpmThmPahO2RJ6EvDLOWhbsK1lRWZblBCYJEatPlbrzzm3efeLftkyeL53FWsJ ehsW3DwkWTJprTQ3nH4K7Bs41khuHMSLFs/jbkFTewC396yu2T8Tkqn2z8/yt0a1QXBI NJBAR3XkvYPLG0acimfPNANiCqvPKy1zpmlzc9hBeOqx2C9oS4Hjh/KwQ+EcGtSMRoad YSjw== X-Gm-Message-State: APjAAAV2q2hxhL2NK9ffwYrKBu+C+HIZjcFMP3UK9QkGsR5Xs11jxkW8 TfwCBC1hUaruvCGMpKQQyzg24S9KUKCWlxz5ZZ2xv42F X-Google-Smtp-Source: APXvYqwvh4qqdVD0IlZ+J09afYLbMSGYAc1By1vDjNQJb4Yg84dm8uZvkjnykUJKtV1OCnu1flWhiBkfOtXNPLqHPwg= X-Received: by 2002:a5e:9607:: with SMTP id a7mr11693241ioq.151.1558280308054; Sun, 19 May 2019 08:38:28 -0700 (PDT) MIME-Version: 1.0 From: Roman Perepelitsa Date: Sun, 19 May 2019 17:38:16 +0200 Message-ID: Subject: Incorrect cursor position when ZLE_RPROMPT_INDENT=0 (with a fix) To: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary="00000000000038e08005893f6848" --00000000000038e08005893f6848 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable To reproduce: ZLE_RPROMPT_INDENT=3D0 PROMPT=3D12 RPROMPT=3D3 Expected behavior: The cursor is positioned after =E2=80=982=E2=80=99. Actual behavior: The cursor is positioned on =E2=80=982=E2=80=99. 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 =3D winw - rprompt_off;+ vcs =3D winw - (rprompt_off ? rprompt_off : 1); /* reset character attributes to that set by the main prompt */ txtchange =3D pmpt_attr; /* @@ -2159,7 +2159,7 @@ moveto(int ln, int cl) const REFRESH_ELEMENT *rep; if (vcs =3D=3D winw) {- if (rprompt_indent =3D=3D 0 && tccan(TCLEFT= )) {+ if (0) { tc_leftcurs(1); vcs--; } else { There is now an if-else with 0 as the condition. I=E2=80=99ve posted the di= ff this way to make it clearer what I=E2=80=99d 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=E2=80=99m 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 =3D winw - rprompt_off;+ vcs =3D winw - (rprompt_off ? rprompt_off : 1); /* reset character attributes to that set by the main prompt */ txtchange =3D pmpt_attr; /* @@ -2159,25 +2159,20 @@ moveto(int ln, int cl) const REFRESH_ELEMENT *rep; if (vcs =3D=3D winw) {- if (rprompt_indent =3D=3D 0 && tccan(TCLEFT= )) {- tc_leftcurs(1);- vcs--;- } else {- vln++, vcs =3D 0;- if (!hasam) {- zputc(&zr_cr);- zputc(&zr_nl);- } else {- if ((vln < nlnct) && nbuf[vln] && nbuf[vln]->chr)- rep =3D nbuf[vln];- else- rep =3D &zr_sp;- zputc(rep);- zputc(&zr_cr);- if ((vln < olnct) && obuf[vln] && obuf[vln]->chr)- *obuf[vln] =3D *rep;- }- }+ vln++, vcs =3D 0;+ if (!hasam) {+ zputc(&zr_cr);+ zputc(&zr_nl);+ } else {+ if ((vln < nlnct) && nbuf[vln] && nbuf[vln]->chr)+ rep =3D nbuf[vln];+ else+ rep =3D &zr_sp;+ zputc(rep);+ zputc(&zr_cr);+ if ((vln < olnct) && obuf[vln] && obuf[vln]->chr)+ *obuf[vln] =3D *rep;+ } } if (ln =3D=3D vln && cl =3D=3D vcs) The same thing on github: https://github.com/zsh-users/zsh/compare/master=E2=80=A6romkatv:rprompt-ind= ent . I=E2=80=99ve verified that it works correctly with ZLE_RPROMPT_INDENT=3D{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. --00000000000038e08005893f6848--