From c429c5f86fb8286bbb28e96985d9cc212155201b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 18 Jun 2024 05:49:33 +0800 Subject: vim-patch:9.1.0495: Matched text isn't highlighted in cmdline pum Problem: Matched text isn't highlighted in cmdline pum. Solution: Use cmdline completion pattern in cmdline mode. (zeertzjq) closes: vim/vim#15029 https://github.com/vim/vim/commit/d8c9340fc67ca19f82ec3e77ec38296424e758cf Cherry-pick syntax.txt change from runtime update. --- test/functional/ui/popupmenu_spec.lua | 60 +++++++++++++++++++++++++++++++++++ test/old/testdir/test_cmdline.vim | 31 ++++++++++++++++++ 2 files changed, 91 insertions(+) (limited to 'test') diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 4ea60194c2..fac863ead0 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -3550,6 +3550,66 @@ describe('builtin popupmenu', function() | ]]) end) + + -- oldtest: Test_wildmenu_pum_hl_match() + it('highlighting matched text in cmdline pum', function() + exec([[ + set wildoptions=pum,fuzzy + hi PmenuMatchSel guifg=Blue guibg=Grey + hi PmenuMatch guifg=Blue guibg=Magenta + ]]) + + feed(':sign plc') + screen:expect([[ + | + {1:~ }|*16 + {1:~ }{s: }{ms:pl}{s:a}{ms:c}{s:e }{1: }| + {1:~ }{n: un}{mn:pl}{n:a}{mn:c}{n:e }{1: }| + :sign place^ | + ]]) + feed('') + screen:expect([[ + | + {1:~ }|*16 + {1:~ }{n: }{mn:pl}{n:a}{mn:c}{n:e }{1: }| + {1:~ }{s: un}{ms:pl}{s:a}{ms:c}{s:e }{1: }| + :sign unplace^ | + ]]) + feed('') + screen:expect([[ + | + {1:~ }|*16 + {1:~ }{n: }{mn:pl}{n:a}{mn:c}{n:e }{1: }| + {1:~ }{n: un}{mn:pl}{n:a}{mn:c}{n:e }{1: }| + :sign plc^ | + ]]) + feed('') + command('set wildoptions-=fuzzy') + feed(':sign un') + screen:expect([[ + | + {1:~ }|*16 + {1:~ }{s: }{ms:un}{s:define }{1: }| + {1:~ }{n: }{mn:un}{n:place }{1: }| + :sign undefine^ | + ]]) + feed('') + screen:expect([[ + | + {1:~ }|*16 + {1:~ }{n: }{mn:un}{n:define }{1: }| + {1:~ }{s: }{ms:un}{s:place }{1: }| + :sign unplace^ | + ]]) + feed('') + screen:expect([[ + | + {1:~ }|*16 + {1:~ }{n: }{mn:un}{n:define }{1: }| + {1:~ }{n: }{mn:un}{n:place }{1: }| + :sign un^ | + ]]) + end) end it("'pumheight'", function() diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index f83f782817..4a637552a6 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -2923,6 +2923,37 @@ func Test_wildmenu_pum_rightleft() call StopVimInTerminal(buf) endfunc +" Test highlighting matched text in cmdline completion popup menu. +func Test_wildmenu_pum_hl_match() + CheckScreendump + + let lines =<< trim END + set wildoptions=pum,fuzzy + hi PmenuMatchSel ctermfg=6 ctermbg=7 + hi PmenuMatch ctermfg=4 ctermbg=225 + END + call writefile(lines, 'Xwildmenu_pum_hl', 'D') + let buf = RunVimInTerminal('-S Xwildmenu_pum_hl', #{rows: 10, cols: 50}) + + call term_sendkeys(buf, ":sign plc\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_1', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_2', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_3', {}) + call term_sendkeys(buf, "\:set wildoptions-=fuzzy\") + call TermWait(buf) + call term_sendkeys(buf, ":sign un\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_4', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_5', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_6', {}) + call term_sendkeys(buf, "\") + + call StopVimInTerminal(buf) +endfunc + " Test for completion after a :substitute command followed by a pipe (|) " character func Test_cmdline_complete_substitute() -- cgit