From 6709f7f8f130377f44c36b2150a167a2afcbdff9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 3 Feb 2024 11:05:38 +0800 Subject: fix(keycodes): simplify S- properly when D- is present (#27316) --- src/nvim/keycodes.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c index c45ad83204..c910d0955a 100644 --- a/src/nvim/keycodes.c +++ b/src/nvim/keycodes.c @@ -758,17 +758,20 @@ static int extract_modifiers(int key, int *modp, const bool simplify, bool *cons { int modifiers = *modp; - // Command-key and ctrl are special - if (!(modifiers & MOD_MASK_CMD) && !(modifiers & MOD_MASK_CTRL)) { - if ((modifiers & MOD_MASK_SHIFT) && ASCII_ISALPHA(key)) { - key = TOUPPER_ASC(key); + if ((modifiers & MOD_MASK_SHIFT) && ASCII_ISALPHA(key)) { + key = TOUPPER_ASC(key); + // With we keep the shift modifier. + // With , and we don't keep the shift modifier. + if (!(modifiers & MOD_MASK_CTRL)) { modifiers &= ~MOD_MASK_SHIFT; } } + // and mean the same thing, always use "H" if ((modifiers & MOD_MASK_CTRL) && ASCII_ISALPHA(key)) { key = TOUPPER_ASC(key); } + if (simplify && (modifiers & MOD_MASK_CTRL) && ((key >= '?' && key <= '_') || ASCII_ISALPHA(key))) { key = CTRL_CHR(key); -- cgit