From 033376aec086a8931229f1999fdfb0c911be332a Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 4 Jul 2016 13:17:45 +0200
Subject: [PATCH] input: consider only O, o and [ as starters of
 multi-character sequences

This prevents many keycode sequences from being misconstrued when a
command key plus other keystrokes accumulate in the input buffer.

This fixes https://savannah.gnu.org/bugs/?48395.
---
 src/winio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/winio.c b/src/winio.c
index 4552db0f..3717d87e 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -373,7 +373,8 @@ int parse_kbinput(WINDOW *win)
 		case 1:
 		    /* Reset the escape counter. */
 		    escapes = 0;
-		    if (get_key_buffer_len() == 0 || key_buffer[0] == 0x1b) {
+		    if ((*kbinput != 'O' && *kbinput != 'o' && *kbinput != '[') ||
+				get_key_buffer_len() == 0 || *key_buffer == 0x1B) {
 			/* One escape followed by a single non-escape:
 			 * meta key sequence mode. */
 			meta_key = TRUE;
-- 
GitLab