From 9852bd743c9bf1029990538f2d89cfa1450fb54c Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 29 Aug 2017 09:18:48 +0000 Subject: Check for complete keys before escape prefix, allows keys to be defined with a leading escape. GitHub issue 1048. --- tty-keys.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'tty-keys.c') diff --git a/tty-keys.c b/tty-keys.c index 6e02bdc1..7c0455f0 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -595,7 +595,17 @@ tty_keys_next(struct tty *tty) } first_key: - /* Handle keys starting with escape. */ + /* Try to lookup complete key. */ + n = tty_keys_next1(tty, buf, len, &key, &size, expired); + if (n == 0) /* found */ + goto complete_key; + if (n == 1) + goto partial_key; + + /* + * If not a complete key, look for key with an escape prefix (meta + * modifier). + */ if (*buf == '\033') { /* Look for a key without the escape. */ n = tty_keys_next1(tty, buf + 1, len - 1, &key, &size, expired); @@ -620,13 +630,6 @@ first_key: goto partial_key; } - /* Try to lookup key. */ - n = tty_keys_next1(tty, buf, len, &key, &size, expired); - if (n == 0) /* found */ - goto complete_key; - if (n == 1) - goto partial_key; - /* * At this point, we know the key is not partial (with or without * escape). So pass it through even if the timer has not expired. -- cgit