From 0f60500a632a01f6573fcba0a9f273c6170bba82 Mon Sep 17 00:00:00 2001 From: Nikhil Benesch Date: Mon, 26 Nov 2018 20:41:23 -0500 Subject: [PATCH] use newlines instead of padded spaces when restoring multi-line histories This is a fix for cockroachdb/cockroach#31843. Contributed upstream to NetBSD [0]. 0: http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit/terminal.c?rev=1.34&content-type=text/x-cvsweb-markup&f=h&only_with_tag=MAIN --- src/terminal.c | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index 9c74fcd..cc0169e 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -509,36 +509,14 @@ terminal_move_to_line(EditLine *el, int where) return; } if ((del = where - el->el_cursor.v) > 0) { - while (del > 0) { - if (EL_HAS_AUTO_MARGINS && - el->el_display[el->el_cursor.v][0] != '\0') { - size_t h = (size_t) - (el->el_terminal.t_size.h - 1); - for (; h > 0 && - el->el_display[el->el_cursor.v][h] == - MB_FILL_CHAR; - h--) - continue; - /* move without newline */ - terminal_move_to_char(el, (int)h); - terminal_overwrite(el, &el->el_display - [el->el_cursor.v][el->el_cursor.h], - (size_t)(el->el_terminal.t_size.h - - el->el_cursor.h)); - /* updates Cursor */ - del--; - } else { - if ((del > 1) && GoodStr(T_DO)) { - terminal_tputs(el, tgoto(Str(T_DO), del, - del), del); - del = 0; - } else { - for (; del > 0; del--) - terminal__putc(el, '\n'); - /* because the \n will become \r\n */ - el->el_cursor.h = 0; - } - } + if ((del > 1) && GoodStr(T_DO)) { + terminal_tputs(el, tgoto(Str(T_DO), del, del), del); + del = 0; + } else { + for (; del > 0; del--) + terminal__putc(el, '\n'); + /* because the \n will become \r\n */ + el->el_cursor.h = 0; } } else { /* del < 0 */ if (GoodStr(T_UP) && (-del > 1 || !GoodStr(T_up)))