diff --git a/src/prompt.c b/src/prompt.c index cd402325..d8d422b2 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -200,9 +200,9 @@ void do_statusbar_verbatim_input(void) bytes = get_verbatim_kbinput(bottomwin, &count); - if (count > 0) + if (0 < count && count < 999) inject_into_answer(bytes, count); - else + else if (count == 0) beep(); free(bytes); diff --git a/src/text.c b/src/text.c index d63af9d8..a981c57f 100644 --- a/src/text.c +++ b/src/text.c @@ -3016,15 +3016,17 @@ void do_verbatim_input(void) /* When something valid was obtained, unsuppress cursor-position display, * insert the bytes into the edit buffer, and blank the status bar. */ - if (count > 0) { + if (0 < count && count < 999) { if (ISSET(CONSTANT_SHOW)) lastmessage = VACUUM; inject(bytes, count); wipe_statusbar(); - } else + } else if (count == 0) /* TRANSLATORS: An invalid verbatim Unicode code was typed. */ statusline(ALERT, _("Invalid code")); + else + wipe_statusbar(); free(bytes); } diff --git a/src/winio.c b/src/winio.c index e4095cc0..f2e3fa98 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1375,7 +1375,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count) #ifndef NANO_TINY /* When the window was resized, abort and return nothing. */ if (keycode == KEY_WINCH) { - *count = 0; + *count = 999; return NULL; } #endif @@ -1397,6 +1397,12 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count) unicode = assemble_unicode(keycode); } + if (keycode == KEY_WINCH) { + *count = 999; + free(yield); + return NULL; + } + /* For an invalid digit, discard its possible continuation bytes. */ if (unicode == INVALID_DIGIT) while (key_buffer_len > 0 && 0x7F < *key_buffer && *key_buffer < 0xC0) @@ -1480,9 +1486,11 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count) keypad(bottomwin, TRUE); } - for (size_t i = 0; i < *count; i++) - bytes[i] = (char)input[i]; - bytes[*count] = '\0'; + if (*count < 999) { + for (size_t i = 0; i < *count; i++) + bytes[i] = (char)input[i]; + bytes[*count] = '\0'; + } free(input);