commit b51eba927324e12271dcb6c4db25e430c4aa6eb9
parent a7b8102f20d5f36c63ec747b40c44cff100da8e3
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon, 8 Sep 2025 11:42:27 +0800
vim-patch:9.1.1738: cmdline-autocompletion breaks history navigation
Problem: cmdline-autocompletion breaks history navigation (ddad431)
Solution: Support history navigation in cmdline autocompletion (Girish
Palya)
Up/Down arrows support history navigation when using wildtrigger()
fixes: vim/vim#18207
closes: vim/vim#18219
https://github.com/vim/vim/commit/708ab7f5fbef95c43a3eb6c0a2ad4e02ad4c2f98
Co-authored-by: Girish Palya <girishji@gmail.com>
Diffstat:
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
@@ -146,6 +146,7 @@ typedef struct {
buf_T *b_im_ptr_buf; ///< buffer where b_im_ptr is valid
int cmdline_type;
bool event_cmdlineleavepre_triggered;
+ bool did_hist_navigate;
} CommandLineState;
typedef struct {
@@ -1254,6 +1255,12 @@ static int command_line_execute(VimState *state, int key)
CommandLineState *s = (CommandLineState *)state;
s->c = key;
+ // Skip wildmenu during history navigation via Up/Down keys
+ if (s->c == K_WILD && s->did_hist_navigate) {
+ s->did_hist_navigate = false;
+ return 1;
+ }
+
if (s->c == K_EVENT || s->c == K_COMMAND || s->c == K_LUA) {
if (s->c == K_EVENT) {
state_handle_k_event();
@@ -2227,6 +2234,7 @@ static int command_line_handle_key(CommandLineState *s)
} else {
switch (command_line_browse_history(s)) {
case CMDLINE_CHANGED:
+ s->did_hist_navigate = true;
return command_line_changed(s);
case GOTO_NORMAL_MODE:
return 0;
diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim
@@ -4986,4 +4986,28 @@ func Test_CmdlineLeave_vchar_keys()
unlet g:leave_key
endfunc
+" Skip wildmenu during history navigation via Up/Down keys
+func Test_skip_wildtrigger_hist_navigation()
+ call Ntest_override("char_avail", 1)
+ cnoremap <F8> <C-R>=wildtrigger()[-1]<CR>
+ set wildmenu
+
+ call feedkeys(":ech\<F8>\<F4>\<C-B>\"\<CR>", "tx")
+ call assert_match('echo*', g:Sline)
+ call assert_equal('"echo', @:)
+
+ call feedkeys(":echom \"foo\"", "tx")
+ call feedkeys(":echom \"foobar\"", "tx")
+ call feedkeys(":ech\<F8>\<C-E>\<UP>\<C-B>\"\<CR>", "tx")
+ call assert_equal('"echom "foobar"', @:)
+ call feedkeys(":ech\<F8>\<C-E>\<UP>\<UP>\<UP>\<C-B>\"\<CR>", "tx")
+ call assert_equal('"echom "foo"', @:)
+ call feedkeys(":ech\<F8>\<C-E>\<UP>\<UP>\<UP>\<Down>\<C-B>\"\<CR>", "tx")
+ call assert_equal('"echom "foobar"', @:)
+
+ call Ntest_override("char_avail", 0)
+ set wildmenu&
+ cunmap <F8>
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab