mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 13:38:34 +00:00
insert-mode: interpret unmapped META as ESC
closes #2454 closes #8213 ref #7972
This commit is contained in:
@@ -847,7 +847,7 @@ static int insert_handle_key(InsertState *s)
|
||||
|
||||
|
||||
case ' ':
|
||||
if (mod_mask != 4) {
|
||||
if (mod_mask != MOD_MASK_CTRL) {
|
||||
goto normalchar;
|
||||
}
|
||||
// FALLTHROUGH
|
||||
@@ -1180,6 +1180,14 @@ static int insert_handle_key(InsertState *s)
|
||||
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!p_paste) {
|
||||
// Trigger InsertCharPre.
|
||||
char_u *str = do_insert_char_pre(s->c);
|
||||
@@ -1432,7 +1440,7 @@ static void ins_ctrl_v(void)
|
||||
* line and will not removed by the redraw */
|
||||
edit_unputchar();
|
||||
clear_showcmd();
|
||||
insert_special(c, FALSE, TRUE);
|
||||
insert_special(c, true, true);
|
||||
revins_chars++;
|
||||
revins_legal++;
|
||||
}
|
||||
@@ -5054,13 +5062,11 @@ static void insert_special(int c, int allow_modmask, int ctrlv)
|
||||
char_u *p;
|
||||
int len;
|
||||
|
||||
/*
|
||||
* Special function key, translate into "<Key>". Up to the last '>' is
|
||||
* inserted with ins_str(), so as not to replace characters in replace
|
||||
* mode.
|
||||
* Only use mod_mask for special keys, to avoid things like <S-Space>,
|
||||
* unless 'allow_modmask' is TRUE.
|
||||
*/
|
||||
// Special function key, translate into "<Key>". Up to the last '>' is
|
||||
// inserted with ins_str(), so as not to replace characters in replace
|
||||
// mode.
|
||||
// Only use mod_mask for special keys, to avoid things like <S-Space>,
|
||||
// unless 'allow_modmask' is TRUE.
|
||||
if (mod_mask & MOD_MASK_CMD) { // Command-key never produces a normal key.
|
||||
allow_modmask = true;
|
||||
}
|
||||
|
@@ -1577,7 +1577,7 @@ vungetc ( /* unget one character (can only be done once!) */
|
||||
old_mouse_col = mouse_col;
|
||||
}
|
||||
|
||||
/// get a character:
|
||||
/// Gets a character:
|
||||
/// 1. from the stuffbuffer
|
||||
/// This is used for abbreviated commands like "D" -> "d$".
|
||||
/// Also used to redo a command for ".".
|
||||
@@ -1595,7 +1595,7 @@ vungetc ( /* unget one character (can only be done once!) */
|
||||
/// if "advance" is FALSE (vpeekc()):
|
||||
/// just look whether there is a character available.
|
||||
///
|
||||
/// When "no_mapping" is zero, checks for mappings in the current mode.
|
||||
/// When `no_mapping` (global) is zero, checks for mappings in the current mode.
|
||||
/// Only returns one byte (of a multi-byte character).
|
||||
/// K_SPECIAL and CSI may be escaped, need to get two more bytes then.
|
||||
static int vgetorpeek(int advance)
|
||||
|
@@ -443,7 +443,7 @@ enum key_extra {
|
||||
#define MOD_MASK_2CLICK 0x20 // use MOD_MASK_MULTI_CLICK
|
||||
#define MOD_MASK_3CLICK 0x40 // use MOD_MASK_MULTI_CLICK
|
||||
#define MOD_MASK_4CLICK 0x60 // use MOD_MASK_MULTI_CLICK
|
||||
#define MOD_MASK_CMD 0x80 // "super" key (OSX/Mac: command-key)
|
||||
#define MOD_MASK_CMD 0x80 // "super" key (macOS: command-key)
|
||||
|
||||
#define MOD_MASK_MULTI_CLICK (MOD_MASK_2CLICK|MOD_MASK_3CLICK| \
|
||||
MOD_MASK_4CLICK)
|
||||
|
Reference in New Issue
Block a user