aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/getchar.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r--src/nvim/getchar.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 00372d4f3d..28ff0cbd59 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -21,6 +21,7 @@
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/input.h"
+#include "nvim/insexpand.h"
#include "nvim/keycodes.h"
#include "nvim/lua/executor.h"
#include "nvim/main.h"
@@ -29,6 +30,7 @@
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
+#include "nvim/mouse.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/ops.h"
@@ -1583,16 +1585,18 @@ int vgetc(void)
vgetc_char = c;
}
- // 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
- // In Terminal mode, however, this is not desirable. #16220
- if (!no_mapping && KeyTyped && !(State & MODE_TERMINAL)
- && (mod_mask == MOD_MASK_ALT || mod_mask == MOD_MASK_META)) {
+ // If mappings are enabled (i.e., not i_CTRL-V) and the user directly typed something with
+ // MOD_MASK_ALT (<M-/<A- modifier) that was not mapped, interpret <M-x> as <Esc>x rather
+ // than as an unbound <M-x> keypress. #8213
+ // In Terminal mode, however, this is not desirable. #16202 #16220
+ // Also do not do this for mouse keys, as terminals encode mouse events as CSI sequences, and
+ // MOD_MASK_ALT has a meaning even for unmapped mouse keys.
+ if (!no_mapping && KeyTyped && mod_mask == MOD_MASK_ALT && !(State & MODE_TERMINAL)
+ && !is_mouse_key(c)) {
mod_mask = 0;
int len = ins_char_typebuf(c, 0);
(void)ins_char_typebuf(ESC, 0);
- ungetchars(len + 3); // The ALT/META modifier takes three more bytes
+ ungetchars(len + 3); // K_SPECIAL KS_MODIFIER MOD_MASK_ALT takes 3 more bytes
continue;
}
@@ -1733,7 +1737,7 @@ static bool at_ins_compl_key(void)
|| ((compl_cont_status & CONT_LOCAL) && (c == Ctrl_N || c == Ctrl_P));
}
-/// Check if typebuf.tb_buf[] contains a modifer plus key that can be changed
+/// Check if typebuf.tb_buf[] contains a modifier plus key that can be changed
/// into just a key, apply that.
/// Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off + "max_offset"].
/// @return the length of the replaced bytes, 0 if nothing changed, -1 for error.
@@ -1807,7 +1811,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)
int local_State = get_real_state();
bool is_plug_map = false;
- // If typehead starts with <Plug> then remap, even for a "noremap" mapping.
+ // If typeahead starts with <Plug> then remap, even for a "noremap" mapping.
if (typebuf.tb_len >= 3
&& typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
&& typebuf.tb_buf[typebuf.tb_off + 1] == KS_EXTRA