# HG changeset patch # User Bram Moolenaar # Date 1602084603 -7200 # Node ID 6325ef9143bc11dc9f89a759a0ff00aaa1e64fb1 # Parent 12f44f93c583418d2ea0070b021d05128ad23ecc patch 8.2.1811: mapping Ctrl-key does not work for '{', '}' and '|' Commit: https://github.com/vim/vim/commit/9a033d7b18651acbb7eda4b7f39a27c01748fb70 Author: Bram Moolenaar Date: Wed Oct 7 17:29:48 2020 +0200 patch 8.2.1811: mapping Ctrl-key does not work for '{', '}' and '|' Problem: Mapping Ctrl-key does not work for '{', '}' and '|'. Solution: Remove the shift modifier. (closes https://github.com/vim/vim/issues/6457) diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -839,8 +839,15 @@ execute a shell command, e.g.: `!ls` Or When modifyOtherKeys is enabled you can map and : > imap [[[ - imap {{{ -Without modifyOtherKeys and are indistinguishable from Esc. + imap {{{ +Without modifyOtherKeys and are indistinguishable from Esc. +Note that is used and not or . This works on most +keyboards. Similarly, is used instead of or and + instead of or . Note that '|' has a special meaning in a +mapping, see |map-bar|. + +WARNING: if you map you may very well break any key codes that start +with Esc. Make sure it comes AFTER other mappings. A known side effect is that in Insert mode the raw escape sequence is inserted after the CTRL-V key. This can be used to check whether modifyOtherKeys is diff --git a/src/misc2.c b/src/misc2.c --- a/src/misc2.c +++ b/src/misc2.c @@ -2974,7 +2974,8 @@ may_adjust_key_for_ctrl(int modifiers, i /* * Some keys already have Shift included, pass them as normal keys. - * Not when Ctrl is also used, because and are different. + * When Ctrl is also used and are different, but should + * be . Same for and . * Also for and . * This includes all printable ASCII characters except numbers and a-z. */ @@ -2989,6 +2990,11 @@ may_remove_shift_modifier(int modifiers, || (key >= '[' && key <= '`') || (key >= '{' && key <= '~'))) return modifiers & ~MOD_MASK_SHIFT; + + if (modifiers == (MOD_MASK_SHIFT | MOD_MASK_CTRL) + && (key == '{' || key == '}' || key == '|')) + return modifiers & ~MOD_MASK_SHIFT; + return modifiers; } diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim --- a/src/testdir/test_termcodes.vim +++ b/src/testdir/test_termcodes.vim @@ -2126,6 +2126,24 @@ endfunc func Test_mapping_works_with_shift_ctrl() call RunTest_mapping_works_with_mods(function('GetEscCodeCSI27'), 'C-S', 6) call RunTest_mapping_works_with_mods(function('GetEscCodeCSIu'), 'C-S', 6) + + new + set timeoutlen=10 + + " Ctrl-Shift-[ actually produces CTRL-Shift-{ which is mapped as + call RunTest_mapping_mods('', '{', function('GetEscCodeCSI27'), 6) + call RunTest_mapping_mods('', '{', function('GetEscCodeCSIu'), 6) + + " Ctrl-Shift-] actually produces CTRL-Shift-} which is mapped as + call RunTest_mapping_mods('', '{', function('GetEscCodeCSI27'), 6) + call RunTest_mapping_mods('', '{', function('GetEscCodeCSIu'), 6) + + " Ctrl-Shift-\ actually produces CTRL-Shift-| which is mapped as + call RunTest_mapping_mods('', '|', function('GetEscCodeCSI27'), 6) + call RunTest_mapping_mods('', '|', function('GetEscCodeCSIu'), 6) + + bwipe! + set timeoutlen& endfunc " Below we also test the "u" code with Alt, This works, but libvterm would not diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1811, +/**/ 1810, /**/ 1809,