# HG changeset patch # User Bram Moolenaar # Date 1643038205 -3600 # Node ID 63179e8300f8d3e732acb82f7fbce2d8fff3a7b2 # Parent b26e0d130e077e83fbea62ad5b527dac711f8c14 patch 8.2.4203: entering a character with CTRL-V may include modifiers Commit: https://github.com/vim/vim/commit/502d8ae3e8ed8b6f8dd2ff175f154f9aa87228ef Author: zeertzjq Date: Mon Jan 24 15:27:50 2022 +0000 patch 8.2.4203: entering a character with CTRL-V may include modifiers Problem: Entering a character with CTRL-V may include modifiers. Solution: Reset "mod_mask" when entering a character with digits after CTRL-V. (closes #9610) diff --git a/src/edit.c b/src/edit.c --- a/src/edit.c +++ b/src/edit.c @@ -1909,6 +1909,11 @@ get_literal(int noReduceKeys) if ((nc == ESC || nc == CSI) && !noReduceKeys) nc = decodeModifyOtherKeys(nc); + if ((mod_mask & ~MOD_MASK_SHIFT) != 0) + // A character with non-Shift modifiers should not be a valid + // character for i_CTRL-V_digit. + break; + #ifdef FEAT_CMDL_INFO if (!(State & CMDLINE) && MB_BYTE2LEN_CHECK(nc) == 1) add_to_showcmd(nc); @@ -1986,7 +1991,11 @@ get_literal(int noReduceKeys) --allow_keys; #endif if (nc) + { vungetc(nc); + // A character typed with i_CTRL-V_digit cannot have modifiers. + mod_mask = 0; + } got_int = FALSE; // CTRL-C typed after CTRL-V is not an interrupt return cc; } diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim --- a/src/testdir/test_edit.vim +++ b/src/testdir/test_edit.vim @@ -1073,14 +1073,16 @@ func Test_edit_DROP() endfunc func Test_edit_CTRL_V() - CheckFeature ebcdic + CheckNotFeature ebcdic + new call setline(1, ['abc']) call cursor(2, 1) + " force some redraws set showmode showcmd - "call test_override_char_avail(1) - call test_override('ALL', 1) + call test_override('char_avail', 1) + call feedkeys("A\\\\\\\", 'tnix') call assert_equal(["abc\x0e\x0c\x02"], getline(1, '$')) @@ -1093,8 +1095,19 @@ func Test_edit_CTRL_V() set norl endif - call test_override('ALL', 0) set noshowmode showcmd + call test_override('char_avail', 0) + + " No modifiers should be applied to the char typed using i_CTRL-V_digit. + call feedkeys(":append\\76c\76\\u3c0j\u3c0\\.\", 'tnix') + call assert_equal('LcLπjπ', getline(2)) + + if has('osx') + " A char with a modifier should not be a valid char for i_CTRL-V_digit. + call feedkeys("o\\\\\\\\\\", 'tnix') + call assert_equal('', getline(3)) + endif + bw! endfunc 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 */ /**/ + 4203, +/**/ 4202, /**/ 4201,