fix(cmdline): make sure pum is removed on leave (#36608)

This commit is contained in:
zeertzjq
2025-11-19 09:40:20 +08:00
committed by GitHub
parent f2619160ae
commit 677446c70f
2 changed files with 23 additions and 6 deletions

View File

@@ -933,6 +933,9 @@ static uint8_t *command_line_enter(int firstc, int count, int indent, bool clear
// sure to still clean up to avoid memory corruption.
if (cmdline_pum_active()) {
cmdline_pum_remove(false);
} else {
// A previous cmdline_pum_remove() may have deferred redraw.
pum_check_clear();
}
wildmenu_cleanup(&ccline);
s->did_wild_list = false;

View File

@@ -549,7 +549,7 @@ describe('cmdline', function()
]])
feed(':TestCmd a<F8>')
screen:expect([[
local s1 = [[
|
{1:~ }|*3
{1:~ }{4: abc1 }{1: }|
@@ -558,13 +558,14 @@ describe('cmdline', function()
{1:~ }{4: abc4 }{1: }|
{1:~ }{4: abc5 }{1: }|
:TestCmd a^ |
]])
]]
screen:expect(s1)
-- Typing a character when pum is open does not close the pum window
-- This is needed to prevent pum window from flickering during
-- ':h cmdline-autocompletion'.
feed('x')
screen:expect([[
local s2 = [[
|
{1:~ }|*3
{1:~ }{4: abc1 }{1: }|
@@ -573,9 +574,10 @@ describe('cmdline', function()
{1:~ }{4: abc4 }{1: }|
{1:~ }{4: abc5 }{1: }|
:TestCmd ax^ |
]])
]]
screen:expect(s2)
-- pum window is closed when no completion candidates are available
-- pum is closed when no completion candidates are available
feed('<F8>')
screen:expect([[
|
@@ -583,7 +585,19 @@ describe('cmdline', function()
:TestCmd ax^ |
]])
feed('<esc>')
feed('<BS><F8>')
screen:expect(s1)
feed('x')
screen:expect(s2)
-- pum is closed when leaving cmdline mode
feed('<Esc>')
screen:expect([[
^ |
{1:~ }|*8
|
]])
end)
-- oldtest: Test_long_line_noselect()