]> granicus.if.org Git - vim/commitdiff
patch 8.2.4237: record buffer wrong if character in Select mode was not typed v8.2.4237
authorzeertzjq <zeertzjq@outlook.com>
Fri, 28 Jan 2022 12:50:43 +0000 (12:50 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 28 Jan 2022 12:50:43 +0000 (12:50 +0000)
Problem:    Record buffer wrong if character in Select mode was not typed.
Solution:   Only delete the tail from the record buffer if the character was
            typed. (closes #9650)

src/normal.c
src/testdir/test_registers.vim
src/version.c

index e69c14196824b67ee68c6222671c182beb049489..21840369f78d3fc0d82ab3872394605f5eb1b85d 100644 (file)
@@ -1054,9 +1054,10 @@ normal_cmd(
        // be mapped in Insert mode.  Required for ":lmap" to work.
        len = ins_char_typebuf(vgetc_char, vgetc_mod_mask);
 
-       // When recording the character will be recorded again, remove the
-       // previously recording.
-       ungetchars(len);
+       // When recording and gotchars() was called the character will be
+       // recorded again, remove the previous recording.
+       if (KeyTyped)
+           ungetchars(len);
 
        if (restart_edit != 0)
            c = 'd';
index 89d9d7cad7c46fae95d2c7f2f4e50c50f5cb9c2b..078b78dfdf39ab859fce11fbfdaa2e68df0ad0c7 100644 (file)
@@ -745,6 +745,17 @@ func Test_record_in_select_mode()
   sil norm \16q0\a0
   sil norm q
   call assert_equal('0ext', getline(1))
+
+  %delete
+  let @r = ''
+  call setline(1, ['abc', 'abc', 'abc'])
+  smap <F2> <Right><Right>,
+  call feedkeys("qrgh\<F2>Dk\<Esc>q", 'xt')
+  call assert_equal("gh\<F2>Dk\<Esc>", @r)
+  norm j0@rj0@@
+  call assert_equal([',Dk', ',Dk', ',Dk'], getline(1, 3))
+  sunmap <F2>
+
   bwipe!
 endfunc
 
index 23b29daf30f0589506eef31c56fcdbc8241e455a..04afe9586cbbb71fe927da271c1b3dde3f56c2fd 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4237,
 /**/
     4236,
 /**/