From d96f296b8ed6f6297869b8c8dc9bb53ccbd38b95 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 4 Dec 2020 16:35:28 +0100 Subject: [PATCH] input: interpret a keystroke as Meta only when an earlier escape was solo This allows using in a macro as an alternative for , but it does require that one does not type by accident when recording a macro as it might modify the subsequent keystroke when the macro is replayed. This fixes https://savannah.gnu.org/bugs/?58904. Bug existed since version 3.0, commit ecc9211a. --- src/winio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/winio.c b/src/winio.c index 86d5c774..2c74ff20 100644 --- a/src/winio.c +++ b/src/winio.c @@ -889,6 +889,7 @@ int convert_to_control(int kbinput) * the function keys (F1-F12), and the numeric keypad with NumLock off. */ int parse_kbinput(WINDOW *win) { + static bool first_escape_was_alone = FALSE; static bool solitary = FALSE; static int escapes = 0; int keycode; @@ -905,6 +906,7 @@ int parse_kbinput(WINDOW *win) /* Remember whether an Esc arrived by itself, and increment * its counter, rolling around on three escapes. */ if (keycode == ESC_CODE) { + first_escape_was_alone = solitary; solitary = (key_buffer_len == 0); if (digit_count > 0) { digit_count = 0; @@ -998,7 +1000,7 @@ int parse_kbinput(WINDOW *win) } else if (digit_count == 0) { /* If the second escape did not arrive alone, it is a Meta * keystroke; otherwise, it is an "Esc Esc control". */ - if (!solitary) { + if (first_escape_was_alone && !solitary) { if (!shifted_metas) keycode = tolower(keycode); meta_key = TRUE;