commit 677446c70f8c3f8c42e31ea20b9c99b44839d268
parent f2619160ae0764e51816e06573c4ee0081a043c9
Author: zeertzjq <zeertzjq@outlook.com>
Date: Wed, 19 Nov 2025 09:40:20 +0800
fix(cmdline): make sure pum is removed on leave (#36608)
Diffstat:
2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
@@ -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;
diff --git a/test/functional/legacy/cmdline_spec.lua b/test/functional/legacy/cmdline_spec.lua
@@ -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()