diff src/getchar.c @ 28053:f615d89a5351 v8.2.4551

patch 8.2.4551: when mapping <Esc> terminal codes are not recognized Commit: https://github.com/vim/vim/commit/bbf84e2737daf3479e059dc7e7da0c50a07a4bf4 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 12 13:48:39 2022 +0000 patch 8.2.4551: when mapping <Esc> terminal codes are not recognized Problem: When mapping <Esc> terminal codes are not recognized. Solution: Specifically recognize a mapping with just <Esc> and check for terminal codes even though there is no partial mapping. (closes #9903)
author Bram Moolenaar <Bram@vim.org>
date Sat, 12 Mar 2022 15:00:04 +0100
parents ac7db4437368
children b9e8f3674090
line wrap: on
line diff
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -2643,7 +2643,12 @@ handle_mapping(
 	    max_mlen = mlen + 1;
     }
 
-    if ((mp == NULL || max_mlen > mp_match_len) && keylen != KEYLEN_PART_MAP)
+    // May check for a terminal code when there is no mapping or only a partial
+    // mapping.  Also check if there is a full mapping with <Esc>, unless timed
+    // out, since that is nearly always a partial match with a terminal code.
+    if ((mp == NULL || max_mlen > mp_match_len
+		    || (mp_match_len == 1 && *mp->m_keys == ESC && !*timedout))
+	    && keylen != KEYLEN_PART_MAP)
     {
 	int	save_keylen = keylen;