From d6aed482403280000627ea8c7103aef22d76936d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 14 Feb 2019 07:57:38 -0800 Subject: linenoise: fix multi-line mode regression. When Enter is input in multi-line mode, a ^M appears instead of advancing to the next line. When the display is refreshed, the ^M's are properly treated as line breaks. * linenoise.c (edit_insert): Let's restructure the conditional ladder here into a switch and handle ENTER by issuing CR-LF. --- linenoise/linenoise.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'linenoise') diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index a83964e5..9869737d 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -1571,12 +1571,23 @@ static int edit_insert(lino_t *l, wchar_t c) { */ wchar_t str[3] = L"^"; - if (c == 0xdc00 || c < ' ') { - str[1] = '@' + (c & 0xff); - } else if (c == 127) { + switch (c) { + case ENTER: + str[0] = '\r'; + str[1] = '\n'; + break; + case 127: str[1] = '?'; - } else { - str[0] = c; + break; + default: + if (c >= ' ') { + str[0] = c; + break; + } + /* fallthrough */ + case 0xdc00: + str[1] = '@' + (c & 0xff); + break; } if (!lino_os.puts_fn(l->tty_ofs, str)) -- cgit v1.2.3