Skip to content

Commit b3b47e5

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.1.1858: v:register not reset after Visual mode command
Problem: v:register not reset after Visual mode command. (laktak) Solution: Reset v:register if Visual mode was active before do_pending_operator() (zeertzjq) fixes: #18579 related: #5305 closes: #18583 Signed-off-by: zeertzjq <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 67860ef commit b3b47e5

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/normal.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,10 @@ normal_cmd(
968968
if (old_mapped_len > 0)
969969
old_mapped_len = typebuf_maplen();
970970

971+
#ifdef FEAT_EVAL
972+
int prev_VIsual_active = VIsual_active;
973+
#endif
974+
971975
// If an operation is pending, handle it. But not for K_IGNORE or
972976
// K_MOUSEMOVE.
973977
if (ca.cmdchar != K_IGNORE && ca.cmdchar != K_MOUSEMOVE)
@@ -984,7 +988,7 @@ normal_cmd(
984988
msg_nowait = FALSE;
985989

986990
#ifdef FEAT_EVAL
987-
if (finish_op)
991+
if (finish_op || prev_VIsual_active)
988992
reset_reg_var();
989993
#endif
990994

src/testdir/test_registers.vim

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,13 @@ func Test_v_register()
699699

700700
let s:register = ''
701701
call feedkeys('"_ddS', 'mx')
702-
call assert_equal('test@', getline('.')) " fails before 8.2.0929
703702
call assert_equal('"', s:register) " fails before 8.2.0929
703+
call assert_equal('test@', getline('.')) " fails before 8.2.0929
704+
705+
let s:register = ''
706+
call feedkeys('V"_dS', 'mx')
707+
call assert_equal('"', s:register)
708+
call assert_equal('test@', getline('.'))
704709

705710
let s:register = ''
706711
call feedkeys('"zS', 'mx')
@@ -719,6 +724,11 @@ func Test_v_register()
719724
call assert_equal('"', s:register) " fails before 8.2.0929
720725
call assert_equal('test@', getline('.')) " fails before 8.2.0929
721726

727+
let s:register = ''
728+
normal V"_dS
729+
call assert_equal('"', s:register)
730+
call assert_equal('test@', getline('.'))
731+
722732
let s:register = ''
723733
execute 'normal "z:call' "s:Put()\n"
724734
call assert_equal('z', s:register)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
1858,
737739
/**/
738740
1857,
739741
/**/

0 commit comments

Comments
 (0)