* [PATCH] move the cursor up only when redisplay is called the first time
@ 2018-09-06 3:47 Yao-Wen Mao
0 siblings, 0 replies; only message in thread
From: Yao-Wen Mao @ 2018-09-06 3:47 UTC (permalink / raw)
To: zsh-workers
[-- 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-09-06 3:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-06 3:47 [PATCH] move the cursor up only when redisplay is called the first time Yao-Wen Mao
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).