Skip to content

Commit 8524102

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.1.2107: :normal may change cmdline history
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 <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 7d22f84 commit 8524102

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/ex_getln.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1871,7 +1871,7 @@ getcmdline_int(
18711871
// that occurs while typing a command should
18721872
// cause the command not to be executed.
18731873

1874-
if (stuff_empty() && typebuf.tb_len == 0)
1874+
if (ex_normal_busy == 0 && stuff_empty() && typebuf.tb_len == 0)
18751875
// There is no pending input from sources other than user input, so
18761876
// Vim is going to wait for the user to type a key. Consider the
18771877
// command line typed even if next key will trigger a mapping.

src/testdir/test_cmdline.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,6 +2675,7 @@ func Test_recalling_cmdline_with_mappings()
26752675
call assert_equal("echo 'bar'", histget(':', -1))
26762676
call assert_equal("echo 'foo'", histget(':', -2))
26772677

2678+
let g:cmdline = ''
26782679
" This command comes completely from a mapping.
26792680
nmap <F3> :echo 'baz'<F2><CR>
26802681
call feedkeys("\<F3>", 'tx')
@@ -2684,6 +2685,15 @@ func Test_recalling_cmdline_with_mappings()
26842685
call assert_equal("echo 'bar'", histget(':', -1))
26852686
call assert_equal("echo 'foo'", histget(':', -2))
26862687

2688+
let g:cmdline = ''
2689+
" A command coming from :normal is ignored in the history even if the keys
2690+
" don't explicitly leave Cmdline mode.
2691+
exe "normal :echo 'baz'\<F2>"
2692+
call assert_equal("echo 'baz'", g:cmdline)
2693+
call assert_equal("echo 'bar'", @:)
2694+
call assert_equal("echo 'bar'", histget(':', -1))
2695+
call assert_equal("echo 'foo'", histget(':', -2))
2696+
26872697
if has('unix')
26882698
new
26892699
call setline(1, ['aaa'])

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
2107,
737739
/**/
738740
2106,
739741
/**/

0 commit comments

Comments
 (0)