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

patch 9.1.1868: v:register is wrong in v_: command

Problem:  v:register is wrong in v_: command (after 9.1.1858).
Solution: Don't reset v:register for OP_COLON (zeertzjq)

related: https://github.com/vim/vim/pull/18583#issuecomment-3418030021

closes: #18597

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2025-10-18 14:37:48 +00:00
committed by Christian Brabandt
parent 5932ed33f7
commit 0124320c97
3 changed files with 42 additions and 5 deletions

View File

@@ -695,6 +695,9 @@ normal_cmd(
int idx;
int set_prevcount = FALSE;
int save_did_cursorhold = did_cursorhold;
#ifdef FEAT_EVAL
int did_visual_op = FALSE;
#endif
CLEAR_FIELD(ca); // also resets ca.retval
ca.oap = oap;
@@ -968,14 +971,18 @@ normal_cmd(
if (old_mapped_len > 0)
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
// K_MOUSEMOVE.
if (ca.cmdchar != K_IGNORE && ca.cmdchar != K_MOUSEMOVE)
{
#ifdef FEAT_EVAL
did_visual_op = VIsual_active && oap->op_type != OP_NOP
// For OP_COLON, do_pending_operator() stuffs ':' into
// the read buffer, which isn't executed immediately.
&& oap->op_type != OP_COLON;
#endif
do_pending_operator(&ca, old_col, FALSE);
}
// Wait for a moment when a message is displayed that will be overwritten
// by the mode message.
@@ -988,7 +995,7 @@ normal_end:
msg_nowait = FALSE;
#ifdef FEAT_EVAL
if (finish_op || prev_VIsual_active)
if (finish_op || did_visual_op)
reset_reg_var();
#endif

View File

@@ -692,7 +692,9 @@ func Test_v_register()
exec 'normal! "' .. v:register .. 'P'
endfunc
nnoremap <buffer> <plug>(test) :<c-u>call s:Put()<cr>
xnoremap <buffer> <plug>(test) :<c-u>call s:Put()<cr>
nmap <buffer> S <plug>(test)
xmap <buffer> S <plug>(test)
let @z = "testz\n"
let @" = "test@\n"
@@ -710,15 +712,41 @@ func Test_v_register()
let s:register = ''
call feedkeys('"zS', 'mx')
call assert_equal('z', s:register)
call assert_equal('testz', getline('.'))
let s:register = ''
call feedkeys('"zSS', 'mx')
call assert_equal('"', s:register)
call assert_equal('test@', getline('.'))
let s:register = ''
call feedkeys("\"z\<Ignore>S", 'mx')
call assert_equal('z', s:register)
call assert_equal('testz', getline('.'))
let s:register = ''
call feedkeys('"_S', 'mx')
call assert_equal('_', s:register)
let s:register = ''
call feedkeys('V"zS', 'mx')
call assert_equal('z', s:register)
call assert_equal('testz', getline('.'))
let s:register = ''
call feedkeys('V"zSS', 'mx')
call assert_equal('"', s:register)
call assert_equal('test@', getline('.'))
let s:register = ''
call feedkeys("V\"z\<Ignore>S", 'mx')
call assert_equal('z', s:register)
call assert_equal('testz', getline('.'))
let s:register = ''
call feedkeys('V"_S', 'mx')
call assert_equal('_', s:register)
let s:register = ''
normal "_ddS
call assert_equal('"', s:register) " fails before 8.2.0929

View File

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