aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/ui/cursor_spec.lua4
-rw-r--r--test/functional/ui/popupmenu_spec.lua117
-rw-r--r--test/old/testdir/test_popup.vim67
3 files changed, 186 insertions, 2 deletions
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua
index f7eb8394bd..619153724b 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -246,11 +246,11 @@ describe('ui/cursor', function()
end
end
if m.hl_id then
- m.hl_id = 64
+ m.hl_id = 66
m.attr = { background = Screen.colors.DarkGray }
end
if m.id_lm then
- m.id_lm = 71
+ m.id_lm = 73
end
end
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
diff --git a/test/old/testdir/test_popup.vim b/test/old/testdir/test_popup.vim
index 5ae2ed5ed5..acebcae1dd 100644
--- a/test/old/testdir/test_popup.vim
+++ b/test/old/testdir/test_popup.vim
@@ -1348,4 +1348,71 @@ func Test_pum_highlights_custom()
call StopVimInTerminal(buf)
endfunc
+" Test match relate highlight group in pmenu
+func Test_pum_highlights_match()
+ CheckScreendump
+ let lines =<< trim END
+ 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 ctermfg=6 ctermbg=225
+ hi PmenuMatch ctermfg=4 ctermbg=225
+ END
+ call writefile(lines, 'Xscript', 'D')
+ let buf = RunVimInTerminal('-S Xscript', {})
+ call TermWait(buf)
+ call term_sendkeys(buf, "i\<C-X>\<C-O>")
+ call TermWait(buf, 50)
+ call term_sendkeys(buf, "fo")
+ call TermWait(buf, 50)
+ call VerifyScreenDump(buf, 'Test_pum_highlights_03', {})
+ call term_sendkeys(buf, "\<ESC>S\<C-x>\<C-O>")
+ call TermWait(buf, 50)
+ call term_sendkeys(buf, "你")
+ call TermWait(buf, 50)
+ call VerifyScreenDump(buf, 'Test_pum_highlights_04', {})
+ call term_sendkeys(buf, "吗")
+ call TermWait(buf, 50)
+ call VerifyScreenDump(buf, 'Test_pum_highlights_05', {})
+
+ if has('rightleft')
+ call term_sendkeys(buf, "\<C-E>\<ESC>u:set rightleft\<CR>")
+ call TermWait(buf, 50)
+ call term_sendkeys(buf, "i\<C-X>\<C-O>")
+ call TermWait(buf, 50)
+ call term_sendkeys(buf, "fo")
+ call TermWait(buf, 50)
+ call VerifyScreenDump(buf, 'Test_pum_highlights_06', {})
+ call term_sendkeys(buf, "\<C-E>\<ESC>u:set norightleft\<CR>")
+ call TermWait(buf)
+ endif
+
+ call term_sendkeys(buf, ":set completeopt-=fuzzy\<CR>")
+ call TermWait(buf)
+ call term_sendkeys(buf, "\<ESC>S\<C-x>\<C-O>")
+ call TermWait(buf, 50)
+ call term_sendkeys(buf, "fo")
+ call TermWait(buf, 50)
+ call VerifyScreenDump(buf, 'Test_pum_highlights_07', {})
+
+ call term_sendkeys(buf, "\<C-E>\<Esc>u")
+ call TermWait(buf)
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab