From ee9a2f0512e8b732e3c6a000974aa7e3f6028989 Mon Sep 17 00:00:00 2001 From: Girish Palya Date: Thu, 18 Sep 2025 19:46:01 +0000 Subject: [PATCH] patch 9.1.1771: complete: some redraw issues with 'autocomplete' Problem: complete: some redraw issues with 'autocomplete' Solution: Fix the issues (Girish Palya) This commit contains the following changes: * Fix that wildtrigger() might leave opened popupmenu around #18298 * Remove blinking message on the command line when a menu item from a loaded buffer is selected during 'autocomplete' * Add a test for PR #18265 to demonstrate why the PR is required for correct 'autocomplete' behavior fixes: #18298 closes: #18328 Signed-off-by: Girish Palya Signed-off-by: Christian Brabandt --- src/ex_getln.c | 1 + src/insexpand.c | 15 +++++++++------ .../Test_update_screen_wildtrigger_1.dump | 10 ++++++++++ src/testdir/test_cmdline.vim | 19 +++++++++++++++++++ src/testdir/test_ins_complete.vim | 9 ++++++++- src/version.c | 2 ++ 6 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 src/testdir/dumps/Test_update_screen_wildtrigger_1.dump diff --git a/src/ex_getln.c b/src/ex_getln.c index f917dccf22..0df08dd718 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -2037,6 +2037,7 @@ getcmdline_int( if (cmdline_pum_active()) { skip_pum_redraw = skip_pum_redraw && !key_is_wc + && !VIM_ISWHITE(c) && (vim_isprintc(c) || c == K_BS || c == Ctrl_H || c == K_DEL || c == K_KDEL || c == Ctrl_W || c == Ctrl_U); diff --git a/src/insexpand.c b/src/insexpand.c index c97f5b2796..d98b5c1b0d 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -6007,12 +6007,15 @@ ins_compl_show_filename(void) MB_PTR_ADV(s); } } - msg_hist_off = TRUE; - vim_snprintf((char *)IObuff, IOSIZE, "%s %s%s", lead, - s > compl_shown_match->cp_fname ? "<" : "", s); - msg((char *)IObuff); - msg_hist_off = FALSE; - redraw_cmdline = FALSE; // don't overwrite! + if (!compl_autocomplete) + { + msg_hist_off = TRUE; + vim_snprintf((char *)IObuff, IOSIZE, "%s %s%s", lead, + s > compl_shown_match->cp_fname ? "<" : "", s); + msg((char *)IObuff); + msg_hist_off = FALSE; + redraw_cmdline = FALSE; // don't overwrite! + } } /* diff --git a/src/testdir/dumps/Test_update_screen_wildtrigger_1.dump b/src/testdir/dumps/Test_update_screen_wildtrigger_1.dump new file mode 100644 index 0000000000..bd0a8141cf --- /dev/null +++ b/src/testdir/dumps/Test_update_screen_wildtrigger_1.dump @@ -0,0 +1,10 @@ +| +0&#ffffff0@74 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|:+0#0000000&|t|e|r|m| |f|o@1> @65 diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index 22e2c00a37..bdba4abff1 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -5088,4 +5088,23 @@ func Test_skip_wildtrigger_hist_navigation() cunmap endfunc +" Issue 18298: wildmenu should be dismissed after wildtrigger and whitespace +func Test_update_screen_after_wildtrigger() + CheckScreendump + let lines =<< trim [SCRIPT] + call test_override("char_avail", 1) + set wildmode=noselect:lastused,full wildmenu wildoptions=pum + autocmd CmdlineChanged : if getcmdcompltype() != 'shellcmd' | call wildtrigger() | endif + [SCRIPT] + call writefile(lines, 'XTest_wildtrigger', 'D') + let buf = RunVimInTerminal('-S XTest_wildtrigger', {'rows': 10}) + + call term_sendkeys(buf, ":term foo") + call TermWait(buf, 50) + call VerifyScreenDump(buf, 'Test_update_screen_wildtrigger_1', {}) + + call term_sendkeys(buf, "\") + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim index 32a89836ca..2bd726b7df 100644 --- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -5247,7 +5247,7 @@ func Test_autocomplete_trigger() call feedkeys("Sazx\\\\0", 'tx!') call assert_equal(['and', 'afoo'], b:matches->mapnew('v:val.word')) - " Test 6: should clear the selected item + " Test 6: should clear the selected item (PR #18265) %d call setline(1, ["foobarfoo", "foobar", "foobarbaz"]) call feedkeys("Gofo\\\\\0", 'tx!') @@ -5262,6 +5262,13 @@ func Test_autocomplete_trigger() call assert_equal(0, b:selected) call assert_equal('foobarbaz', getline(4)) + " Test 7: Remove selection when menu contents change (PR #18265) + %d + call setline(1, ["foobar", "fodxyz", "fodabc"]) + call feedkeys("Gofoo\\\\\d\\\0", 'tx!') + call assert_equal(['fodabc', 'fodxyz'], b:matches->mapnew('v:val.word')) + call assert_equal(-1, b:selected) + bw! call test_override("char_avail", 0) delfunc NonKeywordComplete diff --git a/src/version.c b/src/version.c index bd78cbf1d5..c98d6ccc60 100644 --- a/src/version.c +++ b/src/version.c @@ -724,6 +724,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1771, /**/ 1770, /**/