Cmdline history not updated when mapping both <Up> and <CR>#18607
Closed
zeertzjq wants to merge 1 commit intovim:masterfrom
Closed
Cmdline history not updated when mapping both <Up> and <CR>#18607zeertzjq wants to merge 1 commit intovim:masterfrom
zeertzjq wants to merge 1 commit intovim:masterfrom
Conversation
f60a7b4 to
92d4827
Compare
zeertzjq
commented
Oct 20, 2025
runtime/doc/cmdline.txt
Outdated
Comment on lines
+64
to
+65
| - Only commands that are typed are remembered. A command coming completely | ||
| from a mapping is not put in the history. |
Member
Author
There was a problem hiding this comment.
This also matches :h ": better:
The command-line is only stored in this register when at least
one character of it was typed. Thus it remains unchanged if
the command was completely from a mapping.
There it says "a mapping" instead of "mappings".
Member
There was a problem hiding this comment.
This "was completely" is a bit awkward, should probably be something like this?
Thus it remains unchanged if the command was executed from a mapping.
d8849b5 to
41c2690
Compare
Member
|
How about this on top? diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt
index ff64628e0..58c370c29 100644
--- a/runtime/doc/change.txt
+++ b/runtime/doc/change.txt
@@ -1324,7 +1324,7 @@ and ":put" commands and with CTRL-R.
"@:" to repeat the previous command-line command.
The command-line is only stored in this register when at least
one character of it was typed. Thus it remains unchanged if
- the command was completely from a mapping.
+ the command was executed completely from a mapping.
{not available when compiled without the |+cmdline_hist|
feature}
*quote_#* *quote#*
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 07b5e129a..120313ee0 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -2612,6 +2612,7 @@ func Test_recalling_cmdline_with_mappings()
cnoremap <F2> <Cmd>let g:cmdline = getcmdline()<CR>
cnoremap <CR> <CR>
cnoremap <Up> <Up>
+ let _a = ['a', getreg('a'), getregtype('a')]
call feedkeys(":echo 'foo'\<CR>", 'tx')
call assert_equal("echo 'foo'", @:)
@@ -2655,7 +2656,18 @@ func Test_recalling_cmdline_with_mappings()
call assert_equal("echo 'foo'", g:cmdline)
call assert_equal("echo 'foo'", @:)
+ " a command coming from a mapping is also ignored in the history
+ call feedkeys(':let @a=":echo ''zzz''\<cr>"', 'tx')
+ call feedkeys(":norm @a\<cr>", 'tx')
+ call assert_equal('norm @a', @:)
+ call assert_equal('norm @a', histget(':', -1))
+ call assert_equal('let @a=":echo ''zzz''\<cr>"', histget(':', -2))
+ call assert_equal("echo 'foo'", histget(':', -3))
+ call assert_equal("echo 'bar'", histget(':', -4))
+
+
unlet g:cmdline
+ call call('setreg', _a)
cunmap <F2>
cunmap <CR>
cunmap <Up> |
41c2690 to
b93a7be
Compare
Problem: Cmdline history not updated when mapping both <Up> and <CR>.
Solution: Consider the command typed when in Cmdline mode and there is
no pending input.
fixes: vim#2771
related: neovim/neovim#36256
Although the existing behavior technically does match documentation, the
"completely come from mappings" part is a bit ambiguous, because one may
argue that the command doesn't completely come from mappings as long as
the user has typed a key in Cmdline mode. I'm not entirely sure if this
change will cause problems, but it seems unlikely.
b93a7be to
10c744a
Compare
Member
|
thanks |
zeertzjq
added a commit
to zeertzjq/neovim
that referenced
this pull request
Oct 26, 2025
… <CR>
Problem: Cmdline history not updated when mapping both <Up> and <CR>.
Solution: Consider the command typed when in Cmdline mode and there is
no pending input (zeertzjq).
Although the existing behavior technically does match documentation, the
"completely come from mappings" part is a bit ambiguous, because one may
argue that the command doesn't completely come from mappings as long as
the user has typed a key in Cmdline mode. I'm not entirely sure if this
change will cause problems, but it seems unlikely.
fixes: vim/vim#2771
related: neovim#36256
closes: vim/vim#18607
vim/vim@97b6e8b
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
zeertzjq
added a commit
to zeertzjq/neovim
that referenced
this pull request
Oct 26, 2025
… <CR>
Problem: Cmdline history not updated when mapping both <Up> and <CR>.
Solution: Consider the command typed when in Cmdline mode and there is
no pending input (zeertzjq).
Although the existing behavior technically does match documentation, the
"completely come from mappings" part is a bit ambiguous, because one may
argue that the command doesn't completely come from mappings as long as
the user has typed a key in Cmdline mode. I'm not entirely sure if this
change will cause problems, but it seems unlikely.
fixes: vim/vim#2771
related: neovim#36256
closes: vim/vim#18607
vim/vim@97b6e8b
zeertzjq
added a commit
to neovim/neovim
that referenced
this pull request
Oct 26, 2025
… <CR> (#36334) Problem: Cmdline history not updated when mapping both <Up> and <CR>. Solution: Consider the command typed when in Cmdline mode and there is no pending input (zeertzjq). Although the existing behavior technically does match documentation, the "completely come from mappings" part is a bit ambiguous, because one may argue that the command doesn't completely come from mappings as long as the user has typed a key in Cmdline mode. I'm not entirely sure if this change will cause problems, but it seems unlikely. fixes: vim/vim#2771 related: #36256 closes: vim/vim#18607 vim/vim@97b6e8b
github-actions bot
pushed a commit
to neovim/neovim
that referenced
this pull request
Jan 23, 2026
… <CR> (#36334) Problem: Cmdline history not updated when mapping both <Up> and <CR>. Solution: Consider the command typed when in Cmdline mode and there is no pending input (zeertzjq). Although the existing behavior technically does match documentation, the "completely come from mappings" part is a bit ambiguous, because one may argue that the command doesn't completely come from mappings as long as the user has typed a key in Cmdline mode. I'm not entirely sure if this change will cause problems, but it seems unlikely. fixes: vim/vim#2771 related: #36256 closes: vim/vim#18607 vim/vim@97b6e8b (cherry picked from commit 2407833)
github-actions bot
pushed a commit
to neovim/neovim
that referenced
this pull request
Jan 23, 2026
… <CR> (#36334) Problem: Cmdline history not updated when mapping both <Up> and <CR>. Solution: Consider the command typed when in Cmdline mode and there is no pending input (zeertzjq). Although the existing behavior technically does match documentation, the "completely come from mappings" part is a bit ambiguous, because one may argue that the command doesn't completely come from mappings as long as the user has typed a key in Cmdline mode. I'm not entirely sure if this change will cause problems, but it seems unlikely. fixes: vim/vim#2771 related: #36256 closes: vim/vim#18607 vim/vim@97b6e8b (cherry picked from commit 2407833)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: Cmdline history not updated when mapping both <Up> and <CR>.
Solution: Consider the command typed when in Cmdline mode and there is
no pending input.
fixes: #2771
related: neovim/neovim#36256
Although the existing behavior technically does match documentation, the
"completely come from mappings" part is a bit ambiguous, because one may
argue that the command doesn't completely come from mappings as long as
the user has typed a key in Cmdline mode. I'm not entirely sure if this
change will cause problems, but it seems unlikely.