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

Commit: 
https://github.com/vim/vim/commit/0124320c97b0fbbb44613f42fc1c34fee6181fc8
Author: zeertzjq <[email protected]>
Date:   Sat Oct 18 14:37:48 2025 +0000

    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/normal.c b/src/normal.c
index ead265dc2..63edaa964 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -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
 
diff --git a/src/testdir/test_registers.vim b/src/testdir/test_registers.vim
index 4d04ff7cd..2720937cf 100644
--- a/src/testdir/test_registers.vim
+++ b/src/testdir/test_registers.vim
@@ -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
"
   let @" = "test@
"
@@ -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
diff --git a/src/version.c b/src/version.c
index 5f43d92b0..0d6a5fd12 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1868,
 /**/
     1867,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vA8B7-004zFW-SI%40256bit.org.

Raspunde prin e-mail lui