]> granicus.if.org Git - vim/commitdiff
patch 8.2.4203: entering a character with CTRL-V may include modifiers v8.2.4203
authorzeertzjq <zeertzjq@outlook.com>
Mon, 24 Jan 2022 15:27:50 +0000 (15:27 +0000)
committerBram Moolenaar <Bram@vim.org>
Mon, 24 Jan 2022 15:27:50 +0000 (15:27 +0000)
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)

src/edit.c
src/testdir/test_edit.vim
src/version.c

index 03631293034f886d70bb38b3af7614b9d9ef0fad..ee3caf0dad50057485b98b7638eea8550b3a6ebf 100644 (file)
@@ -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;
 }
index 63226466ee9bc7c54fd95e52429af1921a3fc38f..782e5e0c52a45b8098cec73f58cd468ff4fff51c 100644 (file)
@@ -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\<c-v>\<c-n>\<c-v>\<c-l>\<c-v>\<c-b>\<esc>", '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\<CR>\<C-V>76c\<C-V>76\<C-F2>\<C-V>u3c0j\<C-V>u3c0\<M-F3>\<CR>.\<CR>", 'tnix')
+  call assert_equal('LcL<C-F2>πjπ<M-F3>', getline(2))
+
+  if has('osx')
+    " A char with a modifier should not be a valid char for i_CTRL-V_digit.
+    call feedkeys("o\<C-V>\<D-j>\<C-V>\<D-1>\<C-V>\<D-o>\<C-V>\<D-x>\<C-V>\<D-u>", 'tnix')
+    call assert_equal('<D-j><D-1><D-o><D-x><D-u>', getline(3))
+  endif
+
   bw!
 endfunc
 
index 99a7555b6142fab5ea0f4d169409ce1d454cdea9..c75fe99375b3bc35ffcbd6cfc27a81abebfbdc20 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4203,
 /**/
     4202,
 /**/