patch 9.1.0580: :lmap mapping for keypad key not applied when typed in Select mode
Problem: An :lmap mapping for a printable keypad key is not applied
when typing it in Select mode.
Solution: Change keypad key to ASCII after setting vgetc_char.
(zeertzjq)
closes: #15245
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/getchar.c b/src/getchar.c
index 0a37b7b..9d54377 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1999,6 +1999,43 @@
#endif
}
+ // For a multi-byte character get all the bytes and return the
+ // converted character.
+ // Note: This will loop until enough bytes are received!
+ if (has_mbyte && (n = MB_BYTE2LEN_CHECK(c)) > 1)
+ {
+ ++no_mapping;
+ buf[0] = c;
+ for (i = 1; i < n; ++i)
+ {
+ buf[i] = vgetorpeek(TRUE);
+ if (buf[i] == K_SPECIAL
+#ifdef FEAT_GUI
+ || (buf[i] == CSI)
+#endif
+ )
+ {
+ // Must be a K_SPECIAL - KS_SPECIAL - KE_FILLER
+ // sequence, which represents a K_SPECIAL (0x80),
+ // or a CSI - KS_EXTRA - KE_CSI sequence, which
+ // represents a CSI (0x9B),
+ // or a K_SPECIAL - KS_EXTRA - KE_CSI, which is CSI
+ // too.
+ c = vgetorpeek(TRUE);
+ if (vgetorpeek(TRUE) == KE_CSI && c == KS_EXTRA)
+ buf[i] = CSI;
+ }
+ }
+ --no_mapping;
+ c = (*mb_ptr2char)(buf);
+ }
+
+ if (vgetc_char == 0)
+ {
+ vgetc_mod_mask = mod_mask;
+ vgetc_char = c;
+ }
+
// a keypad or special function key was not mapped, use it like
// its ASCII equivalent
switch (c)
@@ -2062,43 +2099,6 @@
case K_XRIGHT: c = K_RIGHT; break;
}
- // For a multi-byte character get all the bytes and return the
- // converted character.
- // Note: This will loop until enough bytes are received!
- if (has_mbyte && (n = MB_BYTE2LEN_CHECK(c)) > 1)
- {
- ++no_mapping;
- buf[0] = c;
- for (i = 1; i < n; ++i)
- {
- buf[i] = vgetorpeek(TRUE);
- if (buf[i] == K_SPECIAL
-#ifdef FEAT_GUI
- || (buf[i] == CSI)
-#endif
- )
- {
- // Must be a K_SPECIAL - KS_SPECIAL - KE_FILLER
- // sequence, which represents a K_SPECIAL (0x80),
- // or a CSI - KS_EXTRA - KE_CSI sequence, which
- // represents a CSI (0x9B),
- // or a K_SPECIAL - KS_EXTRA - KE_CSI, which is CSI
- // too.
- c = vgetorpeek(TRUE);
- if (vgetorpeek(TRUE) == KE_CSI && c == KS_EXTRA)
- buf[i] = CSI;
- }
- }
- --no_mapping;
- c = (*mb_ptr2char)(buf);
- }
-
- if (vgetc_char == 0)
- {
- vgetc_mod_mask = mod_mask;
- vgetc_char = c;
- }
-
break;
}