Skip to content

Commit 78eb9cc

Browse files
chrisbrabrammool
authored andcommitted
patch 8.2.3439: deleted lines go to wrong yank register
Problem: Deleted lines go to wrong yank register. Solution: Reset y_append when not calling get_yank_register(). (Christian Brabandt, closes #8872)
1 parent 5dfe467 commit 78eb9cc

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

src/ops.c

+2
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ op_delete(oparg_T *oap)
695695
if (op_yank(oap, TRUE, FALSE) == OK) // yank without message
696696
did_yank = TRUE;
697697
}
698+
else
699+
reset_y_append(); // not appending to unnamed register
698700

699701
/*
700702
* Put deleted text into register 1 and shift number registers if the

src/proto/register.pro

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ yankreg_T *get_y_current(void);
55
yankreg_T *get_y_previous(void);
66
void set_y_current(yankreg_T *yreg);
77
void set_y_previous(yankreg_T *yreg);
8+
void reset_y_append(void);
89
int get_expr_register(void);
910
void set_expr_line(char_u *new_line, exarg_T *eap);
1011
char_u *get_expr_line(void);

src/register.c

+7
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ set_y_previous(yankreg_T *yreg)
7474
y_previous = yreg;
7575
}
7676

77+
void
78+
reset_y_append(void)
79+
{
80+
y_append = FALSE;
81+
}
82+
83+
7784
#if defined(FEAT_EVAL) || defined(PROTO)
7885
/*
7986
* Keep the last expression line here, for repeating.

src/testdir/test_registers.vim

+52
Original file line numberDiff line numberDiff line change
@@ -728,4 +728,56 @@ func Test_record_in_insert_mode()
728728
bwipe!
729729
endfunc
730730

731+
" Make sure that y_append is correctly reset
732+
" and the previous register is working as expected
733+
func Test_register_y_append_reset()
734+
new
735+
call setline(1, ['1',
736+
\ '2 ----------------------------------------------------',
737+
\ '3',
738+
\ '4',
739+
\ '5 ----------------------------------------------------',
740+
\ '6',
741+
\ '7',
742+
\ '8 ----------------------------------------------------',
743+
\ '9',
744+
\ '10 aaaaaaa 4.',
745+
\ '11 Game Dbl-Figures Leaders:',
746+
\ '12 Player Pts FG% 3P% FT% RB AS BL ST TO PF EFF',
747+
\ '13 bbbbbbbbb 12 (50 /0 /67 )/ 7/ 3/ 0/ 2/ 3/ 4/+15',
748+
\ '14 cccccc 12 (57 /67 /100)/ 2/ 1/ 1/ 0/ 1/ 3/+12',
749+
\ '15 ddddddd 10 (63 /0 /0 )/ 1/ 3/ 0/ 3/ 5/ 3/ +9',
750+
\ '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',
751+
\ '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',
752+
\ '18 4 3 6 3 2 3 3 4 3 3 7 3 1 4 6 -1 -1 +2 -1 -2',
753+
\ '19 F 13 19 5 10 4 17 22 9 14 32 13 4 20 17 -1 -13 -4 -3 -3 +5'])
754+
11
755+
exe "norm! \"a5dd"
756+
norm! j
757+
exe "norm! \"bY"
758+
norm! 2j
759+
exe "norm! \"BY"
760+
norm! 4k
761+
norm! 5dd
762+
norm! 3k
763+
" The next put should put the content of the unnamed register, not of
764+
" register b!
765+
norm! p
766+
call assert_equal(['1',
767+
\ '2 ----------------------------------------------------',
768+
\ '3',
769+
\ '4',
770+
\ '5 ----------------------------------------------------',
771+
\ '6',
772+
\ '10 aaaaaaa 4.',
773+
\ '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',
774+
\ '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',
775+
\ '18 4 3 6 3 2 3 3 4 3 3 7 3 1 4 6 -1 -1 +2 -1 -2',
776+
\ '19 F 13 19 5 10 4 17 22 9 14 32 13 4 20 17 -1 -13 -4 -3 -3 +5',
777+
\ '7',
778+
\ '8 ----------------------------------------------------',
779+
\ '9'], getline(1,'$'))
780+
bwipe!
781+
endfunc
782+
731783
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3439,
758760
/**/
759761
3438,
760762
/**/

0 commit comments

Comments
 (0)