From 4f6196e91d23f17e6b25ea7356d5bbc5b87d95b6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 14 Mar 2025 07:15:53 +0800 Subject: [PATCH] vim-patch:9.1.1200: cmdline pum not cleared for input() completion (#32879) Problem: Cmdline pum not cleared for input() completion. Solution: Temporary reset RedrawingDisabled in cmdline_pum_cleanup(), like what is done in wildmenu_cleanup() (zeertzjq). fixes: vim/vim#16874 closes: vim/vim#16876 https://github.com/vim/vim/commit/1830e787f6ee9828151284c44b494b801c677ee9 No code change is needed in Nvim, as RedrawingDisabled does not prevent the compositor from removing a grid. --- test/functional/legacy/cmdline_spec.lua | 71 +++++++++++++++++++++++++ test/old/testdir/test_cmdline.vim | 31 +++++++++++ 2 files changed, 102 insertions(+) diff --git a/test/functional/legacy/cmdline_spec.lua b/test/functional/legacy/cmdline_spec.lua index 62e77e9b85..94ef85591d 100644 --- a/test/functional/legacy/cmdline_spec.lua +++ b/test/functional/legacy/cmdline_spec.lua @@ -115,6 +115,77 @@ describe('cmdline', function() ]]) end) + -- oldtest: Test_wildmenu_with_input_func() + it('wildmenu works with input() function', function() + local screen = Screen.new(60, 8) + screen:add_extra_attr_ids({ + [100] = { background = Screen.colors.Yellow, foreground = Screen.colors.Black }, + }) + + feed(":call input('Command? ', '', 'command')") + screen:expect([[ + | + {1:~ }|*6 + Command? ^ | + ]]) + feed('ech') + screen:expect([[ + | + {1:~ }|*5 + {100:echo}{3: echoerr echohl echomsg echon }| + Command? echo^ | + ]]) + feed('') + screen:expect([[ + | + {1:~ }|*6 + Command? echo ^ | + ]]) + feed('bufn') + screen:expect([[ + | + {1:~ }|*5 + {100:bufname(}{3: bufnr( }| + Command? echo bufname(^ | + ]]) + feed('') + + command('set wildoptions+=pum') + + feed(":call input('Command? ', '', 'command')") + screen:expect([[ + | + {1:~ }|*6 + Command? ^ | + ]]) + feed('ech') + screen:expect([[ + | + {1:~ }| + {1:~ }{12: echo }{1: }| + {1:~ }{4: echoerr }{1: }| + {1:~ }{4: echohl }{1: }| + {1:~ }{4: echomsg }{1: }| + {1:~ }{4: echon }{1: }| + Command? echo^ | + ]]) + feed('') + screen:expect([[ + | + {1:~ }|*6 + Command? echo ^ | + ]]) + feed('bufn') + screen:expect([[ + | + {1:~ }|*4 + {1:~ }{12: bufname( }{1: }| + {1:~ }{4: bufnr( }{1: }| + Command? echo bufname(^ | + ]]) + feed('') + end) + -- oldtest: Test_redraw_in_autocmd() it('cmdline cursor position is correct after :redraw with cmdheight=2', function() local screen = Screen.new(30, 6) diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index 639a4c1d32..075bdae8d1 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -212,6 +212,37 @@ func Test_wildmenu_screendump() call StopVimInTerminal(buf) endfunc +func Test_wildmenu_with_input_func() + CheckScreendump + + let buf = RunVimInTerminal('-c "set wildmenu"', {'rows': 8}) + + call term_sendkeys(buf, ":call input('Command? ', '', 'command')\") + call VerifyScreenDump(buf, 'Test_wildmenu_input_func_1', {}) + call term_sendkeys(buf, "ech\") + call VerifyScreenDump(buf, 'Test_wildmenu_input_func_2', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_input_func_3', {}) + call term_sendkeys(buf, "bufn\") + call VerifyScreenDump(buf, 'Test_wildmenu_input_func_4', {}) + call term_sendkeys(buf, "\") + + call term_sendkeys(buf, ":set wildoptions+=pum\") + + call term_sendkeys(buf, ":call input('Command? ', '', 'command')\") + call VerifyScreenDump(buf, 'Test_wildmenu_input_func_5', {}) + call term_sendkeys(buf, "ech\") + call VerifyScreenDump(buf, 'Test_wildmenu_input_func_6', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_input_func_7', {}) + call term_sendkeys(buf, "bufn\") + call VerifyScreenDump(buf, 'Test_wildmenu_input_func_8', {}) + call term_sendkeys(buf, "\") + + " clean up + call StopVimInTerminal(buf) +endfunc + func Test_redraw_in_autocmd() CheckScreendump