From 20298ce679dbf21c07c8fe2161724a12424f1e69 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 19 Jun 2020 21:46:52 +0200 Subject: [PATCH] patch 8.2.1015: popup filter gets key with modifier prepended Problem: Popup filter gets key with modifier prepended when using modifyOtherKeys. Solution: Remove the shift modifier when it is included in the key, also when the Alt or Meta modifier is used. --- src/misc2.c | 8 +++++--- src/term.c | 7 +++++-- src/testdir/test_popupwin.vim | 8 +++++++- src/version.c | 2 ++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/misc2.c b/src/misc2.c index 41b9f711e7..649cb65c9b 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -2929,9 +2929,11 @@ extract_modifiers(int key, int *modp, int simplify, int *did_simplify) if ((modifiers & MOD_MASK_SHIFT) && ASCII_ISALPHA(key)) { key = TOUPPER_ASC(key); - // With and we keep the shift modifier. - // With and we don't keep the shift modifier. - if (simplify || modifiers == MOD_MASK_SHIFT) + // With we keep the shift modifier. + // With , and we don't keep the shift modifier. + if (simplify || modifiers == MOD_MASK_SHIFT + || modifiers == (MOD_MASK_SHIFT | MOD_MASK_ALT) + || modifiers == (MOD_MASK_SHIFT | MOD_MASK_META)) modifiers &= ~MOD_MASK_SHIFT; } diff --git a/src/term.c b/src/term.c index c4ca33e32d..1556c2eecc 100644 --- a/src/term.c +++ b/src/term.c @@ -4772,11 +4772,14 @@ handle_key_with_modifier( // Some keys already have Shift included, pass them as // normal keys. Not when Ctrl is also used, because // and are different. - if (modifiers == MOD_MASK_SHIFT + // Also for and . + if ((modifiers == MOD_MASK_SHIFT + || modifiers == (MOD_MASK_SHIFT | MOD_MASK_ALT) + || modifiers == (MOD_MASK_SHIFT | MOD_MASK_META)) && ((key >= '@' && key <= 'Z') || key == '^' || key == '_' || (key >= '{' && key <= '~'))) - modifiers = 0; + modifiers &= ~MOD_MASK_SHIFT; // When used with Ctrl we always make a letter upper case, // so that mapping and are the same. Typing diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 2188c2c6a9..b6f718c842 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -2079,9 +2079,9 @@ func Test_popup_scrollbar() " check size with wrapping lines call term_sendkeys(buf, "j") call VerifyScreenDump(buf, 'Test_popupwin_scroll_12', {}) - call term_sendkeys(buf, "x") " clean up + call term_sendkeys(buf, "x") call StopVimInTerminal(buf) call delete('XtestPopupScroll') endfunc @@ -3347,6 +3347,12 @@ func Test_popupwin_filter_input_multibyte() call feedkeys("\u301b", 'xt') call assert_equal([0xe3, 0x80, 0x9b], g:bytes) + if has('unix') + " with modifyOtherKeys does not include a modifier sequence + call feedkeys("\[27;4;65~", 'Lx!') + call assert_equal([0xc3, 0x81], g:bytes) + endif + call popup_clear() delfunc MyPopupFilter unlet g:bytes diff --git a/src/version.c b/src/version.c index 3ccf1dd094..8b5ad4e483 100644 --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1015, /**/ 1014, /**/