]> granicus.if.org Git - vim/commitdiff
patch 8.2.3439: deleted lines go to wrong yank register v8.2.3439
authorChristian Brabandt <cb@256bit.org>
Tue, 14 Sep 2021 16:55:51 +0000 (18:55 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 14 Sep 2021 16:55:51 +0000 (18:55 +0200)
Problem:    Deleted lines go to wrong yank register.
Solution:   Reset y_append when not calling get_yank_register(). (Christian
            Brabandt, closes #8872)

src/ops.c
src/proto/register.pro
src/register.c
src/testdir/test_registers.vim
src/version.c

index fa6a4c4d1f8c53874afacea3b38a7dee69788165..dedeebfb288971cbb1cafb6df1d6195f483948c6 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -695,6 +695,8 @@ op_delete(oparg_T *oap)
            if (op_yank(oap, TRUE, FALSE) == OK)   // yank without message
                did_yank = TRUE;
        }
+       else
+           reset_y_append(); // not appending to unnamed register
 
        /*
         * Put deleted text into register 1 and shift number registers if the
index a3a6e5016fbac03ff6833d3626ef52f755acb485..d9f166994f62603886a772072224824d37359de4 100644 (file)
@@ -5,6 +5,7 @@ yankreg_T *get_y_current(void);
 yankreg_T *get_y_previous(void);
 void set_y_current(yankreg_T *yreg);
 void set_y_previous(yankreg_T *yreg);
+void reset_y_append(void);
 int get_expr_register(void);
 void set_expr_line(char_u *new_line, exarg_T *eap);
 char_u *get_expr_line(void);
index 161587423258a272a4493f4a406f71cec556cc92..b821a68d5832e025a77e7dbf3312db9f9857e2a4 100644 (file)
@@ -74,6 +74,13 @@ set_y_previous(yankreg_T *yreg)
     y_previous = yreg;
 }
 
+    void
+reset_y_append(void)
+{
+    y_append = FALSE;
+}
+
+
 #if defined(FEAT_EVAL) || defined(PROTO)
 /*
  * Keep the last expression line here, for repeating.
index 58f51911149e545becac479853eb0fda548177f4..e4285e6eefa6b83c5154b6c3b12c7cea3740af7c 100644 (file)
@@ -728,4 +728,56 @@ func Test_record_in_insert_mode()
   bwipe!
 endfunc
 
+" Make sure that y_append is correctly reset
+" and the previous register is working as expected
+func Test_register_y_append_reset()
+  new
+  call setline(1, ['1',
+    \ '2 ----------------------------------------------------',
+    \ '3',
+    \ '4',
+    \ '5 ----------------------------------------------------',
+    \ '6',
+    \ '7',
+    \ '8 ----------------------------------------------------',
+    \ '9',
+    \ '10 aaaaaaa 4.',
+    \ '11 Game Dbl-Figures Leaders:',
+    \ '12 Player Pts FG% 3P% FT% RB AS BL ST TO PF EFF',
+    \ '13 bbbbbbbbb 12 (50 /0 /67 )/ 7/ 3/ 0/ 2/ 3/ 4/+15',
+    \ '14 cccccc 12 (57 /67 /100)/ 2/ 1/ 1/ 0/ 1/ 3/+12',
+    \ '15 ddddddd 10 (63 /0 /0 )/ 1/ 3/ 0/ 3/ 5/ 3/ +9',
+    \ '16 4 5-15 0-3 2-2 5-12 1-1 3-4 33.3 0.0 100 41.7 100 75 12 14',
+    \ '17 F 23-55 2-10 9-11 23-52 3-13 26-29 41.8 20 81.8 44.2 23.1 89.7 57 75',
+    \ '18 4 3 6 3 2 3 3 4 3 3 7 3 1 4 6 -1 -1 +2 -1 -2',
+    \ '19 F 13 19 5 10 4 17 22 9 14 32 13 4 20 17 -1 -13 -4 -3 -3 +5'])
+  11
+  exe "norm! \"a5dd"
+  norm! j
+  exe "norm! \"bY"
+  norm! 2j
+  exe "norm! \"BY"
+  norm! 4k
+  norm! 5dd
+  norm! 3k
+  " The next put should put the content of the unnamed register, not of
+  " register b!
+  norm! p
+  call assert_equal(['1',
+    \ '2 ----------------------------------------------------',
+    \ '3',
+    \ '4',
+    \ '5 ----------------------------------------------------',
+    \ '6',
+    \ '10 aaaaaaa 4.',
+    \ '16 4 5-15 0-3 2-2 5-12 1-1 3-4 33.3 0.0 100 41.7 100 75 12 14',
+    \ '17 F 23-55 2-10 9-11 23-52 3-13 26-29 41.8 20 81.8 44.2 23.1 89.7 57 75',
+    \ '18 4 3 6 3 2 3 3 4 3 3 7 3 1 4 6 -1 -1 +2 -1 -2',
+    \ '19 F 13 19 5 10 4 17 22 9 14 32 13 4 20 17 -1 -13 -4 -3 -3 +5',
+    \ '7',
+    \ '8 ----------------------------------------------------',
+    \ '9'], getline(1,'$'))
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index c803e5bb573bf7df6da350bcf4d3cbc3fb224194..47afcedb0534ccc58dae665a051085db3c7da9e7 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3439,
 /**/
     3438,
 /**/