mirror of
https://github.com/neovim/neovim.git
synced 2025-09-26 21:18:34 +00:00
fix(input): resolve isolated (non-ALT/META) mappings #13109
Problem:
Since 2f06413dfb
#13042, "ESC+c" sequence is treated as "ESC c"
instead of "M-c" (ALT/META+c) when not mapped, aka "fallthrough"
behavior. But "isolated" (non-ALT/META) mappings to ESC and c were not
resolved. This behavior is especially confusing for the TUI.
Solution:
Resolve isolated ESC, c mappings when there is no M-c mapping.
Change ins_char_typebuf() to escape CSI, K_SPECIAL.
fixes #13086
fixes #15869
This commit is contained in:
@@ -1000,6 +1000,18 @@ void ins_char_typebuf(int c)
|
||||
buf[3] = NUL;
|
||||
} else {
|
||||
buf[utf_char2bytes(c, buf)] = NUL;
|
||||
char_u *p = buf;
|
||||
while (*p) {
|
||||
if ((uint8_t)(*p) == CSI || (uint8_t)(*p) == K_SPECIAL) {
|
||||
bool is_csi = (uint8_t)(*p) == CSI;
|
||||
memmove(p + 3, p + 1, STRLEN(p + 1) + 1);
|
||||
*p++ = K_SPECIAL;
|
||||
*p++ = is_csi ? KS_EXTRA : KS_SPECIAL;
|
||||
*p++ = is_csi ? KE_CSI : KE_FILLER;
|
||||
} else {
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
(void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent);
|
||||
}
|
||||
@@ -1573,9 +1585,9 @@ int vgetc(void)
|
||||
if (!no_mapping && KeyTyped
|
||||
&& (mod_mask == MOD_MASK_ALT || mod_mask == MOD_MASK_META)) {
|
||||
mod_mask = 0;
|
||||
stuffcharReadbuff(c);
|
||||
u_sync(false);
|
||||
c = ESC;
|
||||
ins_char_typebuf(c);
|
||||
ins_char_typebuf(ESC);
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
|
Reference in New Issue
Block a user