From 0da1e4b1c52464cdddfb6643b0ec7099add04e2e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 24 Jan 2026 07:57:49 +0800 Subject: [PATCH] vim-patch:9.1.2107: :normal may change cmdline history (#37523) 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: vim/vim#19237 https://github.com/vim/vim/commit/85241020e808a74221a4befa367ceeda76af7ee0 (cherry picked from commit f10a1dcf4d73768dc056c058f8a6bebdfc6bd3be) --- src/nvim/ex_getln.c | 2 +- test/old/testdir/test_cmdline.vim | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index aa8212a92b..7e2571a659 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1004,7 +1004,7 @@ static int command_line_check(VimState *state) // 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. diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index 2fc1a60856..a0f8ce8a03 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -2644,6 +2644,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 :echo 'baz' call feedkeys("\", 'tx') @@ -2653,6 +2654,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'\" + 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'])