1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed = helpers.clear, helpers.feed
local source = helpers.source
describe('ui/ext_popupmenu', function()
local screen
before_each(function()
clear()
screen = Screen.new(60, 8)
screen:attach({rgb=true, ext_popupmenu=true})
screen:set_default_attr_ids({
[1] = {bold=true, foreground=Screen.colors.Blue},
[2] = {bold = true},
})
end)
it('works', function()
source([[
function! TestComplete() abort
call complete(1, ['foo', 'bar', 'spam'])
return ''
endfunction
]])
local expected = {
{'foo', '', '', ''},
{'bar', '', '', ''},
{'spam', '', '', ''},
}
feed('o<C-r>=TestComplete()<CR>')
screen:expect{grid=[[
|
foo^ |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{2:-- INSERT --} |
]], popupmenu={
items=expected,
pos=0,
anchor={1,0},
}}
feed('<c-p>')
screen:expect{grid=[[
|
^ |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{2:-- INSERT --} |
]], popupmenu={
items=expected,
pos=-1,
anchor={1,0},
}}
-- down moves the selection in the menu, but does not insert anything
feed('<down><down>')
screen:expect{grid=[[
|
^ |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{2:-- INSERT --} |
]], popupmenu={
items=expected,
pos=1,
anchor={1,0},
}}
feed('<cr>')
screen:expect{grid=[[
|
bar^ |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{2:-- INSERT --} |
]]}
end)
end)
|