From 77d74b5d811f6507a69e90cff77a903073c733da Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 12 Oct 2017 20:00:25 +0200 Subject: [PATCH] input: flush the keystroke buffer upon any kind of error condition This stops the execution of a macro or a string bind whenever something unexpected happens, to prevent the waiting keystrokes from doing things that were not intended. Especially this prevents an infinite loop: when during the recording of a macro the `runmacro` keystroke is typed in some menu (where the keystroke is not bound), and the macro is later replayed in a way that results in exiting from that menu before the `runmacro` keystroke gets replayed... This fixes https://savannah.gnu.org/bugs/?65301. The issue was reported by `correctmost`. Bug existed since version 2.9.0, since the macro feature was introduced. --- src/winio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/winio.c b/src/winio.c index 25bfc462..19929f46 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2308,6 +2308,10 @@ void statusline(message_type importance, const char *msg, ...) int colorpair; va_list ap; + /* Drop all waiting keystrokes upon any kind of "error". */ + if (importance >= AHEM) + waiting_codes = 0; + /* Ignore a message with an importance that is lower than the last one. */ if (importance < lastmessage && lastmessage > NOTICE) return;