Merge pull request #13042 from godlygeek/unmapped_meta_is_esc

Treat unmapped ALT/META as ESC+c in all modes

Closes #7972
This commit is contained in:
James McCoy
2020-10-05 22:07:52 -04:00
committed by GitHub
9 changed files with 68 additions and 12 deletions

View File

@@ -1254,14 +1254,6 @@ check_pum:
normalchar:
// Insert a normal character.
if (mod_mask == MOD_MASK_ALT || mod_mask == MOD_MASK_META) {
// Unmapped ALT/META chord behaves like ESC+c. #8213
stuffcharReadbuff(ESC);
stuffcharReadbuff(s->c);
u_sync(false);
break;
}
if (!p_paste) {
// Trigger InsertCharPre.
char_u *str = do_insert_char_pre(s->c);

View File

@@ -1528,6 +1528,17 @@ int vgetc(void)
c = utf_ptr2char(buf);
}
// If mappings are enabled (i.e., not Ctrl-v) and the user directly typed
// something with a meta- or alt- modifier that was not mapped, interpret
// <M-x> as <Esc>x rather than as an unbound meta keypress. #8213
if (!no_mapping && KeyTyped
&& (mod_mask == MOD_MASK_ALT || mod_mask == MOD_MASK_META)) {
mod_mask = 0;
stuffcharReadbuff(c);
u_sync(false);
c = ESC;
}
break;
}
}