zsh-workers
 help / color / mirror / code / Atom feed
From: Yao-Wen Mao <leomaoyw@gmail.com>
To: zsh-workers@zsh.org
Subject: [PATCH] move the cursor up only when redisplay is called the first time
Date: Thu, 6 Sep 2018 11:47:10 +0800	[thread overview]
Message-ID: <CAGAiaBGm5HBN3fvkhWcssBYo1ED4W6=CivCiD_hQU6Bpgcg6ng@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1463 bytes --]

Last year I found an issue about reset-prompt with multiline prompt.
(Thread: `reset-prompt` multiple times cause multiline PROMPT redraw in the
wrong place)

When using mutliline prompt, ` lprompth` will be  greater than 1. Now if
`redisplay` in zle_refresh.c is called multiple times without calling
`resetvideo`, then the cursor position will move to the wrong place.

To verify this, I create an ugly fix and rebuild to check that the problem
is gone. I add a flag `cursor_moved` to make sure that the cursor will only
move once before calling `resetvideo`.
I think this may not be a proper fix, is there anyone can help me to create
a better fix?

diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index d0dd1ef06..1d1b2526e 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -210,6 +210,8 @@ int predisplaylen, postdisplaylen;

 static int default_atr_on, special_atr_on;

+static int cursor_moved;
+
 /*
  * Array of region highlights, no special termination.
  * The first element (0) always describes the region between
@@ -771,6 +773,8 @@ resetvideo(void)
     if (showinglist > 0)
  showinglist = -2;
     trashedzle = 0;
+
+    cursor_moved = 0;
 }

 /*
@@ -2433,7 +2437,9 @@ redisplay(UNUSED(char **args))
 {
     moveto(0, 0);
     zputc(&zr_cr); /* extra care */
-    tc_upcurs(lprompth - 1);
+    if (!cursor_moved)
+ tc_upcurs(lprompth - 1);
+    cursor_moved = 1;
     resetneeded = 1;
     clearflag = 0;
     return 0;

                 reply	other threads:[~2018-09-06  3:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CAGAiaBGm5HBN3fvkhWcssBYo1ED4W6=CivCiD_hQU6Bpgcg6ng@mail.gmail.com' \
    --to=leomaoyw@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).