0
0
mirror of https://github.com/vim/vim.git synced 2025-10-20 08:14:18 -04:00

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 <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2025-10-16 18:17:45 +00:00
committed by Christian Brabandt
parent 67860efe5b
commit b3b47e540d
3 changed files with 18 additions and 2 deletions

View File

@@ -968,6 +968,10 @@ normal_cmd(
if (old_mapped_len > 0) if (old_mapped_len > 0)
old_mapped_len = typebuf_maplen(); old_mapped_len = typebuf_maplen();
#ifdef FEAT_EVAL
int prev_VIsual_active = VIsual_active;
#endif
// If an operation is pending, handle it. But not for K_IGNORE or // If an operation is pending, handle it. But not for K_IGNORE or
// K_MOUSEMOVE. // K_MOUSEMOVE.
if (ca.cmdchar != K_IGNORE && ca.cmdchar != K_MOUSEMOVE) if (ca.cmdchar != K_IGNORE && ca.cmdchar != K_MOUSEMOVE)
@@ -984,7 +988,7 @@ normal_end:
msg_nowait = FALSE; msg_nowait = FALSE;
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
if (finish_op) if (finish_op || prev_VIsual_active)
reset_reg_var(); reset_reg_var();
#endif #endif

View File

@@ -699,8 +699,13 @@ func Test_v_register()
let s:register = '' let s:register = ''
call feedkeys('"_ddS', 'mx') call feedkeys('"_ddS', 'mx')
call assert_equal('test@', getline('.')) " fails before 8.2.0929
call assert_equal('"', s:register) " fails before 8.2.0929 call assert_equal('"', s:register) " fails before 8.2.0929
call assert_equal('test@', getline('.')) " fails before 8.2.0929
let s:register = ''
call feedkeys('V"_dS', 'mx')
call assert_equal('"', s:register)
call assert_equal('test@', getline('.'))
let s:register = '' let s:register = ''
call feedkeys('"zS', 'mx') call feedkeys('"zS', 'mx')
@@ -719,6 +724,11 @@ func Test_v_register()
call assert_equal('"', s:register) " fails before 8.2.0929 call assert_equal('"', s:register) " fails before 8.2.0929
call assert_equal('test@', getline('.')) " fails before 8.2.0929 call assert_equal('test@', getline('.')) " fails before 8.2.0929
let s:register = ''
normal V"_dS
call assert_equal('"', s:register)
call assert_equal('test@', getline('.'))
let s:register = '' let s:register = ''
execute 'normal "z:call' "s:Put()\n" execute 'normal "z:call' "s:Put()\n"
call assert_equal('z', s:register) call assert_equal('z', s:register)

View File

@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1858,
/**/ /**/
1857, 1857,
/**/ /**/