From 2dd86b9075466550685daea56ba2f28cb7d0b6a1 Mon Sep 17 00:00:00 2001 From: Yurii Monakov Date: Tue, 10 Oct 2023 11:16:39 +0300 Subject: cli: Consume invalid escape sequences early Unexpected 'Esc' key presses are accumulated internally, even if it is already clear that the current escape sequence is invalid. This results in weird behaviour. For example, the next character after 'Esc' key simply disappears from input and 'Unknown command' is printed after 'Enter'. This commit fixes some issues with extra 'Esc' keys entered by user: 1. Sequence right after autoboot stop gives: => nknown command 'ry 'help' => 2. Sequence

gives: => ri Unknown command 'ri' - try 'help' => 3. Extra 'Esc' key presses break backspace functionality. Signed-off-by: Yurii Monakov Reviewed-by: Simon Glass --- common/cli_getch.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common/cli_getch.c') diff --git a/common/cli_getch.c b/common/cli_getch.c index 61d4cb261b8..0ee79087774 100644 --- a/common/cli_getch.c +++ b/common/cli_getch.c @@ -46,6 +46,8 @@ static int cli_ch_esc(struct cli_ch_state *cch, int ichar, case 1: if (ichar == '[' || ichar == 'O') act = ESC_SAVE; + else + act = ESC_CONVERTED; break; case 2: switch (ichar) { -- cgit v1.2.3