aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/popupmenu_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-05-24 19:18:11 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-05-24 19:18:11 +0000
commitff7ed8f586589d620a806c3758fac4a47a8e7e15 (patch)
tree729bbcb92231538fa61dab6c3d890b025484b7f5 /test/functional/ui/popupmenu_spec.lua
parent376914f419eb08fdf4c1a63a77e1f035898a0f10 (diff)
parent28c04948a1c887a1cc0cb64de79fa32631700466 (diff)
downloadrneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.gz
rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.bz2
rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'test/functional/ui/popupmenu_spec.lua')
-rw-r--r--test/functional/ui/popupmenu_spec.lua255
1 files changed, 172 insertions, 83 deletions
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index 1f0d20f66d..8f8604eecb 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -1,17 +1,19 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
-local assert_alive = helpers.assert_alive
-local clear, feed = helpers.clear, helpers.feed
-local source = helpers.source
-local insert = helpers.insert
-local api = helpers.api
-local async_meths = helpers.async_meths
-local command = helpers.command
-local fn = helpers.fn
-local eq = helpers.eq
-local pcall_err = helpers.pcall_err
-local exec_lua = helpers.exec_lua
-local exec = helpers.exec
+
+local assert_alive = n.assert_alive
+local clear, feed = n.clear, n.feed
+local source = n.source
+local insert = n.insert
+local api = n.api
+local async_meths = n.async_meths
+local command = n.command
+local fn = n.fn
+local eq = t.eq
+local pcall_err = t.pcall_err
+local exec_lua = n.exec_lua
+local exec = n.exec
describe('ui/ext_popupmenu', function()
local screen
@@ -1171,6 +1173,10 @@ describe('builtin popupmenu', function()
[6] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
[7] = { background = Screen.colors.Yellow }, -- Search
[8] = { foreground = Screen.colors.Red },
+ kn = { foreground = Screen.colors.Red, background = Screen.colors.Magenta },
+ 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 },
})
screen:attach({ ext_multigrid = multigrid })
end)
@@ -1588,13 +1594,13 @@ describe('builtin popupmenu', function()
describe('floating window preview #popup', function()
it('pum popup preview', function()
--row must > 10
- screen:try_resize(30, 11)
+ screen:try_resize(40, 11)
exec([[
funct Omni_test(findstart, base)
if a:findstart
return col(".") - 1
endif
- return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three"}]
+ return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "looooooooooooooong"}]
endfunc
set omnifunc=Omni_test
set completeopt=menu,popup
@@ -1602,94 +1608,185 @@ describe('builtin popupmenu', function()
funct Set_info()
let comp_info = complete_info()
if comp_info['selected'] == 2
- call nvim_complete_set(comp_info['selected'], {"info": "3info"})
+ call nvim__complete_set(comp_info['selected'], {"info": "3info"})
endif
endfunc
autocmd CompleteChanged * call Set_info()
]])
feed('Gi<C-x><C-o>')
-
--floating preview in right
if multigrid then
screen:expect {
grid = [[
## grid 1
- [2:------------------------------]|*10
- [3:------------------------------]|
+ [2:----------------------------------------]|*10
+ [3:----------------------------------------]|
## grid 2
- one^ |
- {1:~ }|*9
+ one^ |
+ {1:~ }|*9
## grid 3
- {2:-- }{5:match 1 of 3} |
+ {2:-- }{5:match 1 of 3} |
## grid 4
{n:1info}|
{n: }|
## grid 5
- {s:one }|
- {n:two }|
- {n:three }|
+ {s:one }|
+ {n:two }|
+ {n:looooooooooooooong }|
]],
float_pos = {
[5] = { -1, 'NW', 2, 1, 0, false, 100 },
- [4] = { 1001, 'NW', 1, 1, 15, true, 50 },
+ [4] = { 1001, 'NW', 1, 1, 19, false, 50 },
+ },
+ win_viewport = {
+ [2] = {
+ win = 1000,
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 3,
+ linecount = 1,
+ sum_scroll_delta = 0,
+ },
+ [4] = {
+ win = 1001,
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 0,
+ linecount = 1,
+ sum_scroll_delta = 0,
+ },
},
}
else
screen:expect {
grid = [[
- one^ |
- {s:one }{n:1info}{1: }|
- {n:two }{1: }|
- {n:three }{1: }|
- {1:~ }|*6
- {2:-- }{5:match 1 of 3} |
+ one^ |
+ {s:one }{n:1info}{1: }|
+ {n:two }{1: }|
+ {n:looooooooooooooong }{1: }|
+ {1:~ }|*6
+ {2:-- }{5:match 1 of 3} |
]],
- unchanged = true,
}
end
- -- test nvim_complete_set_info
- feed('<C-N><C-N>')
- vim.uv.sleep(10)
+ -- info window position should be adjusted when new leader add
+ feed('<C-P>o')
if multigrid then
screen:expect {
grid = [[
## grid 1
- [2:------------------------------]|*10
- [3:------------------------------]|
+ [2:----------------------------------------]|*10
+ [3:----------------------------------------]|
## grid 2
- three^ |
- {1:~ }|*9
+ o^ |
+ {1:~ }|*9
## grid 3
- {2:-- }{5:match 3 of 3} |
+ {2:-- }{8:Back at original} |
## grid 4
- {n:3info}|
+ {n:1info}|
{n: }|
## grid 5
{n:one }|
- {n:two }|
- {s:three }|
]],
float_pos = {
[5] = { -1, 'NW', 2, 1, 0, false, 100 },
- [4] = { 1001, 'NW', 1, 1, 15, true, 50 },
+ [4] = { 1001, 'NW', 1, 1, 15, false, 50 },
+ },
+ win_viewport = {
+ [2] = {
+ win = 1000,
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 1,
+ linecount = 1,
+ sum_scroll_delta = 0,
+ },
+ [4] = {
+ win = 1001,
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 0,
+ linecount = 1,
+ sum_scroll_delta = 0,
+ },
},
}
else
screen:expect {
grid = [[
- three^ |
- {n:one 3info}{1: }|
- {n:two }{1: }|
- {s:three }{1: }|
- {1:~ }|*6
- {2:-- }{5:match 3 of 3} |
+ o^ |
+ {n:one 1info}{1: }|
+ {1:~ }{n: }{1: }|
+ {1:~ }|*7
+ {2:-- }{8:Back at original} |
+ ]],
+ }
+ end
+
+ -- test nvim__complete_set_info
+ feed('<ESC>cc<C-X><C-O><C-N><C-N>')
+ vim.uv.sleep(10)
+ if multigrid then
+ screen:expect {
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*10
+ [3:----------------------------------------]|
+ ## grid 2
+ looooooooooooooong^ |
+ {1:~ }|*9
+ ## grid 3
+ {2:-- }{5:match 3 of 3} |
+ ## grid 5
+ {n:one }|
+ {n:two }|
+ {s:looooooooooooooong }|
+ ## grid 6
+ {n:3info}|
+ {n: }|
+ ]],
+ float_pos = {
+ [5] = { -1, 'NW', 2, 1, 0, false, 100 },
+ [6] = { 1002, 'NW', 1, 1, 19, false, 50 },
+ },
+ win_viewport = {
+ [2] = {
+ win = 1000,
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 18,
+ linecount = 1,
+ sum_scroll_delta = 0,
+ },
+ [6] = {
+ win = 1002,
+ topline = 0,
+ botline = 2,
+ curline = 0,
+ curcol = 0,
+ linecount = 1,
+ sum_scroll_delta = 0,
+ },
+ },
+ }
+ else
+ screen:expect {
+ grid = [[
+ looooooooooooooong^ |
+ {n:one 3info}{1: }|
+ {n:two }{1: }|
+ {s:looooooooooooooong }{1: }|
+ {1:~ }|*6
+ {2:-- }{5:match 3 of 3} |
]],
}
end
- -- make sure info has set
- feed('<C-y>')
- eq('3info', exec_lua('return vim.v.completed_item.info'))
-- preview in left
feed('<ESC>cc')
@@ -1699,24 +1796,24 @@ describe('builtin popupmenu', function()
screen:expect {
grid = [[
## grid 1
- [2:------------------------------]|*10
- [3:------------------------------]|
+ [2:----------------------------------------]|*10
+ [3:----------------------------------------]|
## grid 2
- itesttesttesttesttesone^t |
- {1:~ }|*9
+ itesttesttesttesttesone^t |
+ {1:~ }|*9
## grid 3
- {2:-- }{5:match 1 of 3} |
+ {2:-- }{5:match 1 of 3} |
## grid 5
- {s: one }|
- {n: two }|
- {n: three }|
- ## grid 6
+ {s: one }|
+ {n: two }|
+ {n: looooooooooooooong }|
+ ## grid 7
{n:1info}|
{n: }|
]],
float_pos = {
+ [7] = { 1003, 'NW', 1, 1, 14, false, 50 },
[5] = { -1, 'NW', 2, 1, 19, false, 100 },
- [6] = { 1002, 'NW', 1, 1, 1, true, 50 },
},
win_viewport = {
[2] = {
@@ -1728,8 +1825,8 @@ describe('builtin popupmenu', function()
linecount = 1,
sum_scroll_delta = 0,
},
- [6] = {
- win = 1002,
+ [7] = {
+ win = 1003,
topline = 0,
botline = 2,
curline = 0,
@@ -1742,12 +1839,12 @@ describe('builtin popupmenu', function()
else
screen:expect {
grid = [[
- itesttesttesttesttesone^t |
- {1:~}{n:1info}{1: }{s: one }{1: }|
- {1:~}{n: }{1: }{n: two }{1: }|
- {1:~ }{n: three }{1: }|
- {1:~ }|*6
- {2:-- }{5:match 1 of 3} |
+ itesttesttesttesttesone^t |
+ {1:~ }{n:1info}{s: one }{1: }|
+ {1:~ }{n: two }{1: }|
+ {1:~ }{n: looooooooooooooong }{1: }|
+ {1:~ }|*6
+ {2:-- }{5:match 1 of 3} |
]],
}
end
@@ -2942,7 +3039,7 @@ describe('builtin popupmenu', function()
|
{3:[No Name] }|
{1::}sign define |
- {1::}sign defin^e |
+ {1::}sign define^ |
{1:~ }|*4
{4:[Command Line] }|
:sign define |
@@ -4477,23 +4574,15 @@ describe('builtin popupmenu', function()
hi PmenuExtra guifg=White guibg=Magenta
hi PmenuExtraSel guifg=Black guibg=Grey
]])
- local attrs = screen:get_default_attr_ids()
- attrs.kn = { foreground = Screen.colors.Red, background = Screen.colors.Magenta }
- attrs.ks = { foreground = Screen.colors.Red, background = Screen.colors.Grey }
- attrs.xn = { foreground = Screen.colors.White, background = Screen.colors.Magenta }
- attrs.xs = { foreground = Screen.colors.Black, background = Screen.colors.Grey }
feed('iaw<C-X><C-u>')
- screen:expect(
- [[
+ screen:expect([[
aword1^ |
{s:aword1 }{ks:W }{xs:extra text 1 }{1: }|
{n:aword2 }{kn:W }{xn:extra text 2 }{1: }|
{n:aword3 }{kn:W }{xn:extra text 3 }{1: }|
{1:~ }|*3
{2:-- }{5:match 1 of 3} |
- ]],
- attrs
- )
+ ]])
end)
end)
end