]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.2107: :normal may change cmdline history v9.1.2107
authorzeertzjq <zeertzjq@outlook.com>
Fri, 23 Jan 2026 19:21:42 +0000 (19:21 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 23 Jan 2026 19:21:42 +0000 (19:21 +0000)
Problem:  :normal may change cmdline history if the keys don't
          explicitly leave Cmdline mode (after 9.1.1872).
Solution: Check ex_normal_busy (zeertzjq)

closes: #19237

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/ex_getln.c
src/testdir/test_cmdline.vim
src/version.c

index 65d4c6957726c20c47b783fa4f87da308e376fd9..ce28088d56ddcb38fdb9e7dbfd2656eba7371710 100644 (file)
@@ -1871,7 +1871,7 @@ getcmdline_int(
                                // that occurs while typing a command should
                                // cause the command not to be executed.
 
-       if (stuff_empty() && typebuf.tb_len == 0)
+       if (ex_normal_busy == 0 && stuff_empty() && typebuf.tb_len == 0)
            // There is no pending input from sources other than user input, so
            // Vim is going to wait for the user to type a key.  Consider the
            // command line typed even if next key will trigger a mapping.
index ea018d5932604fea69982bd0608905d73aa7ba64..419d487233bc5a8c529da2fb57a1d39f779159ed 100644 (file)
@@ -2675,6 +2675,7 @@ func Test_recalling_cmdline_with_mappings()
   call assert_equal("echo 'bar'", histget(':', -1))
   call assert_equal("echo 'foo'", histget(':', -2))
 
+  let g:cmdline = ''
   " This command comes completely from a mapping.
   nmap <F3> :echo 'baz'<F2><CR>
   call feedkeys("\<F3>", 'tx')
@@ -2684,6 +2685,15 @@ func Test_recalling_cmdline_with_mappings()
   call assert_equal("echo 'bar'", histget(':', -1))
   call assert_equal("echo 'foo'", histget(':', -2))
 
+  let g:cmdline = ''
+  " A command coming from :normal is ignored in the history even if the keys
+  " don't explicitly leave Cmdline mode.
+  exe "normal :echo 'baz'\<F2>"
+  call assert_equal("echo 'baz'", g:cmdline)
+  call assert_equal("echo 'bar'", @:)
+  call assert_equal("echo 'bar'", histget(':', -1))
+  call assert_equal("echo 'foo'", histget(':', -2))
+
   if has('unix')
     new
     call setline(1, ['aaa'])
index 5017e1d7b90373ef7f6be42f4b89698715ae7fff..6e02d540a941f665164070b25afa73fd5a3bc45f 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2107,
 /**/
     2106,
 /**/