Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] move the cursor up only when redisplay is called the first time



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;


Messages sorted by: Reverse Date, Date, Thread, Author