From 23af871f37ca7a572311f6ec3d72f6e2afb271fd Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 14 Feb 2019 07:27:52 -0800 Subject: linenoise: bugfix: vertical skip problem. This relates to the optimized insert at the end of the line. The following bug manifests itself. When the cursor is not at the bottom of the screen (e.g. fresh terminal after a clear screen), if blank lines are added to the buffer and then backspace is hit, the cursor strangely jumps down by multiple lines prior to the refresh. In a Windows CMD.EXE window, this shows up even at the bottom of the screen, because the CMD.EXE console responds to a downward movement (ESC[B) beyond the bottom row by scrolling the screen, rather than clipping the movement. * linenoise/linenoise.c (refresh_multiline): When doing the elided refresh (l->need_refresh == 2), we must update not only l->maxrows but also l->oldrow. Otherwise when we do the real update, it will think that the cursor is on the first line, and try to move down to the last line. --- linenoise/linenoise.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 9869737d..7e22d21f 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -1146,8 +1146,10 @@ static void refresh_multiline(lino_t *l) { if (rows > l->maxrows) l->maxrows = rows; - if (l->need_refresh == 2) + if (l->need_refresh == 2) { + l->oldrow = nrow; return; + } /* First step: clear all the lines used before. To do so start by * going to the last row. */ -- cgit v1.2.3