vim-patch:9.1.1872: Cmdline history not updated when mapping <Up> and <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: neovim/neovim#36256
closes: vim/vim#18607

97b6e8b424
This commit is contained in:
zeertzjq
2025-10-26 22:19:32 +08:00
committed by GitHub
parent 07461bac27
commit 2407833ba1
4 changed files with 78 additions and 3 deletions

View File

@@ -1038,6 +1038,13 @@ 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) {
// 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.
s->some_key_typed = true;
}
// Trigger SafeState if nothing is pending.
may_trigger_safestate(s->xpc.xp_numfiles <= 0);