From 36361d6e4a189e0d53a26bdaa8d9aa5db791b6d7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 8 Aug 2025 21:18:21 +0800 Subject: [PATCH] vim-patch:9.1.1604: completion: incsearch highlight might be lost (#35236) Problem: completion: incsearch highlight might be lost after search completion (Hirohito Higashi) Solution: Restore incsearch highlight after dismissing pum with Ctrl-E (Girish Palya) related: vim/vim#17870 closes: vim/vim#17891 https://github.com/vim/vim/commit/04c9e78cd33216dfd2cc59b748d1e267d6920c9a This change actually isn't needed as Nvim doesn't call update_screen() to redraw pum, but it doesn't hurt either. Co-authored-by: Girish Palya --- src/nvim/ex_getln.c | 12 +++++------- test/functional/legacy/cmdline_spec.lua | 15 +++++++++++++++ test/old/testdir/test_cmdline.vim | 6 ++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index d36d1b1818..23b4bf2984 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1489,13 +1489,11 @@ static int command_line_execute(VimState *state, int key) // If already used to cancel/accept wildmenu, don't process the key further. if (wild_type == WILD_CANCEL || wild_type == WILD_APPLY) { // Apply search highlighting - if (wild_type == WILD_APPLY) { - if (s->is_state.winid != curwin->handle) { - init_incsearch_state(&s->is_state); - } - if (KeyTyped || vpeekc() == NUL) { - may_do_incsearch_highlighting(s->firstc, s->count, &s->is_state); - } + if (s->is_state.winid != curwin->handle) { + init_incsearch_state(&s->is_state); + } + if (KeyTyped || vpeekc() == NUL) { + may_do_incsearch_highlighting(s->firstc, s->count, &s->is_state); } return command_line_not_changed(s); } diff --git a/test/functional/legacy/cmdline_spec.lua b/test/functional/legacy/cmdline_spec.lua index 091fe59ee3..5e11f47967 100644 --- a/test/functional/legacy/cmdline_spec.lua +++ b/test/functional/legacy/cmdline_spec.lua @@ -484,6 +484,21 @@ describe('cmdline', function() /the^ | ]]) + -- 'incsearch' highlight is restored after dismissing popup (Ctrl_E) + feed('') + command('set wop=pum is nohls') + feed('gg/th') + screen:expect([[ + the | + {2:th}ese | + the | + foobar | + thethe | + thethere | + {1:~ }|*3 + /th^ | + ]]) + feed('') end) diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index 7b1c7de690..2cad916624 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -4659,6 +4659,12 @@ func Test_search_wildmenu_screendump() call term_sendkeys(buf, "\\") call VerifyScreenDump(buf, 'Test_search_wildmenu_8', {}) + " 'incsearch' highlight is restored after dismissing popup (Ctrl_E) + call term_sendkeys(buf, "\:set wop=pum is hls&\") + call term_sendkeys(buf, "gg/th\\") + call TermWait(buf, 50) + call VerifyScreenDump(buf, 'Test_search_wildmenu_9', {}) + call term_sendkeys(buf, "\") call StopVimInTerminal(buf) endfunc