From a08ca026f0e0b7bc595fcf5b3280b17fbf53197d Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 20 Jul 2020 11:05:39 +0200 Subject: [PATCH] input: reset the counters when a three-digit sequence is not completed When is followed by digit 0 or 1 or 2 but then NOT two more digits follow, then both the escape counter and the digit counter should start afresh when a new ESC code arrives. This fixes https://savannah.gnu.org/bugs/?58788. Bug existed since before version 2.0.6. --- src/winio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/winio.c b/src/winio.c index 13d4cd14..cd33adc1 100644 --- a/src/winio.c +++ b/src/winio.c @@ -895,8 +895,10 @@ int parse_kbinput(WINDOW *win) if (keycode == ESC_CODE) { /* Increment the escape counter, but trim an overabundance. */ escapes++; - if (escapes > 3) + if (escapes > 3 || digit_count > 0) { + digit_count = 0; escapes = 1; + } /* Take note when an Esc arrived by itself. */ solitary = (key_buffer_len == 0); return ERR;