aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/popupmenu_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-06-13 14:08:50 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-06-15 04:47:23 +0800
commitdc4037f612c6f3bbc76890adfa638d48ec238eee (patch)
tree97e79ba5672c7e6190a8379a2f7d1869f48cbf7e /test/functional/ui/popupmenu_spec.lua
parentfd950d4998a497cb4258d35af72408105900296a (diff)
downloadrneovim-dc4037f612c6f3bbc76890adfa638d48ec238eee.tar.gz
rneovim-dc4037f612c6f3bbc76890adfa638d48ec238eee.tar.bz2
rneovim-dc4037f612c6f3bbc76890adfa638d48ec238eee.zip
vim-patch:9.1.0476: Cannot see matched text in popup menu
Problem: Cannot see matched text in popup menu Solution: Introduce 2 new highlighting groups: PmenuMatch and PmenuMatchSel (glepnir) closes: vim/vim#14694 https://github.com/vim/vim/commit/40c1c3317d92f8c2adadf744fab72e4458e2a9fa Co-authored-by: glepnir <glephunter@gmail.com>
Diffstat (limited to 'test/functional/ui/popupmenu_spec.lua')
-rw-r--r--test/functional/ui/popupmenu_spec.lua117
1 files changed, 117 insertions, 0 deletions
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index cc21a797e3..0ce0fe4eab 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -1177,6 +1177,8 @@ describe('builtin popupmenu', function()
ks = { foreground = Screen.colors.Red, background = Screen.colors.Grey },
xn = { foreground = Screen.colors.White, background = Screen.colors.Magenta },
xs = { foreground = Screen.colors.Black, background = Screen.colors.Grey },
+ mn = { foreground = Screen.colors.Blue, background = Screen.colors.White },
+ ms = { foreground = Screen.colors.Green, background = Screen.colors.White },
})
screen:attach({ ext_multigrid = multigrid })
end)
@@ -4585,6 +4587,121 @@ describe('builtin popupmenu', function()
]])
end)
end)
+
+ -- oldtest: Test_pum_highlights_match()
+ it('can highlight matched text', function()
+ exec([[
+ func Omni_test(findstart, base)
+ if a:findstart
+ return col(".")
+ endif
+ return {
+ \ 'words': [
+ \ { 'word': 'foo',},
+ \ { 'word': 'foobar',},
+ \ { 'word': 'fooBaz',},
+ \ { 'word': 'foobala',},
+ \ { 'word': '你好',},
+ \ { 'word': '你好吗',},
+ \ { 'word': '你不好吗',},
+ \ { 'word': '你可好吗',},
+ \]}
+ endfunc
+ set omnifunc=Omni_test
+ set completeopt=menu,noinsert,fuzzy
+ hi PmenuMatchSel guifg=Green guibg=White
+ hi PmenuMatch guifg=Blue guibg=White
+ ]])
+ feed('i<C-X><C-O>')
+ local pum_start = [[
+ ^ |
+ {s:foo }{1: }|
+ {n:foobar }{1: }|
+ {n:fooBaz }{1: }|
+ {n:foobala }{1: }|
+ {n:你好 }{1: }|
+ {n:你好吗 }{1: }|
+ {n:你不好吗 }{1: }|
+ {n:你可好吗 }{1: }|
+ {1:~ }|*10
+ {2:-- }{5:match 1 of 8} |
+ ]]
+ screen:expect(pum_start)
+ feed('fo')
+ screen:expect([[
+ fo^ |
+ {ms:fo}{s:o }{1: }|
+ {mn:fo}{n:obar }{1: }|
+ {mn:fo}{n:oBaz }{1: }|
+ {mn:fo}{n:obala }{1: }|
+ {1:~ }|*14
+ {2:-- }{5:match 1 of 8} |
+ ]])
+ feed('<Esc>S<C-X><C-O>')
+ screen:expect(pum_start)
+ feed('你')
+ screen:expect([[
+ 你^ |
+ {ms:你}{s:好 }{1: }|
+ {mn:你}{n:好吗 }{1: }|
+ {mn:你}{n:不好吗 }{1: }|
+ {mn:你}{n:可好吗 }{1: }|
+ {1:~ }|*14
+ {2:-- }{5:match 1 of 8} |
+ ]])
+ feed('吗')
+ screen:expect([[
+ 你吗^ |
+ {ms:你}{s:好}{ms:吗}{s: }{1: }|
+ {mn:你}{n:不好}{mn:吗}{n: }{1: }|
+ {mn:你}{n:可好}{mn:吗}{n: }{1: }|
+ {1:~ }|*15
+ {2:-- }{5:match 1 of 8} |
+ ]])
+
+ feed('<C-E><Esc>')
+ command('set rightleft')
+ feed('S<C-X><C-O>')
+ screen:expect([[
+ ^ |
+ {1: }{s: oof}|
+ {1: }{n: raboof}|
+ {1: }{n: zaBoof}|
+ {1: }{n: alaboof}|
+ {1: }{n: 好你}|
+ {1: }{n: 吗好你}|
+ {1: }{n: 吗好不你}|
+ {1: }{n: 吗好可你}|
+ {1: ~}|*10
+ {2:-- }{5:match 1 of 8} |
+ ]])
+ feed('fo')
+ screen:expect([[
+ ^ of|
+ {1: }{s: o}{ms:of}|
+ {1: }{n: rabo}{mn:of}|
+ {1: }{n: zaBo}{mn:of}|
+ {1: }{n: alabo}{mn:of}|
+ {1: ~}|*14
+ {2:-- }{5:match 1 of 8} |
+ ]])
+ feed('<C-E><Esc>')
+ command('set norightleft')
+
+ command('set completeopt-=fuzzy')
+ feed('S<C-X><C-O>')
+ screen:expect(pum_start)
+ feed('fo')
+ screen:expect([[
+ fo^ |
+ {ms:fo}{s:o }{1: }|
+ {mn:fo}{n:obar }{1: }|
+ {mn:fo}{n:oBaz }{1: }|
+ {mn:fo}{n:obala }{1: }|
+ {1:~ }|*14
+ {2:-- }{5:match 1 of 8} |
+ ]])
+ end)
end
end