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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear, command, eq = n.clear, n.command, t.eq
local insert = n.insert
local api = n.api
local assert_alive = n.assert_alive
describe('ui/ext_tabline', function()
local screen
local event_tabs, event_curtab, event_curbuf, event_buffers
before_each(function()
clear()
screen = Screen.new(25, 5)
screen:attach({ rgb = true, ext_tabline = true })
function screen:_handle_tabline_update(curtab, tabs, curbuf, buffers)
event_curtab = curtab
event_tabs = tabs
event_curbuf = curbuf
event_buffers = buffers
end
end)
it('publishes UI events', function()
command('tabedit another-tab')
local expected_tabs = {
{ tab = 1, name = '[No Name]' },
{ tab = 2, name = 'another-tab' },
}
screen:expect {
grid = [[
^ |
{1:~ }|*3
|
]],
condition = function()
eq(2, event_curtab)
eq(expected_tabs, event_tabs)
end,
}
command('tabNext')
screen:expect {
grid = [[
^ |
{1:~ }|*3
|
]],
condition = function()
eq(1, event_curtab)
eq(expected_tabs, event_tabs)
end,
}
end)
it('buffer UI events', function()
local expected_buffers_initial = {
{ buffer = 1, name = '[No Name]' },
}
screen:expect {
grid = [[
^ |
{1:~ }|*3
|
]],
condition = function()
eq(1, event_curbuf)
eq(expected_buffers_initial, event_buffers)
end,
}
command('badd another-buffer')
command('bnext')
local expected_buffers = {
{ buffer = 1, name = '[No Name]' },
{ buffer = 2, name = 'another-buffer' },
}
screen:expect {
grid = [[
^ |
{1:~ }|*3
|
]],
condition = function()
eq(2, event_curbuf)
eq(expected_buffers, event_buffers)
end,
}
end)
end)
describe('tabline', function()
local screen
before_each(function()
clear()
screen = Screen.new(42, 5)
screen:attach()
end)
it('redraws when tabline option is set', function()
command('set tabline=asdf')
command('set showtabline=2')
screen:expect {
grid = [[
{2:asdf }|
^ |
{1:~ }|*2
|
]],
}
command('set tabline=jkl')
screen:expect {
grid = [[
{2:jkl }|
^ |
{1:~ }|*2
|
]],
}
end)
it('click definitions do not leak memory #21765', function()
command('set tabline=%@MyClickFunc@MyClickText%T')
command('set showtabline=2')
command('redrawtabline')
end)
it('clicks work with truncated double-width label #24187', function()
insert('tab1')
command('tabnew')
insert('tab2')
command('tabprev')
api.nvim_set_option_value('tabline', '%1T口口%2Ta' .. ('b'):rep(38) .. '%999Xc', {})
screen:expect {
grid = [[
{2:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
tab^1 |
{1:~ }|*2
|
]],
}
assert_alive()
api.nvim_input_mouse('left', 'press', '', 0, 0, 1)
screen:expect {
grid = [[
{2:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
tab^2 |
{1:~ }|*2
|
]],
}
api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
screen:expect {
grid = [[
{2:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
tab^1 |
{1:~ }|*2
|
]],
}
api.nvim_input_mouse('left', 'press', '', 0, 0, 39)
screen:expect {
grid = [[
{2:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
tab^2 |
{1:~ }|*2
|
]],
}
api.nvim_input_mouse('left', 'press', '', 0, 0, 40)
screen:expect {
grid = [[
tab^1 |
{1:~ }|*3
|
]],
}
end)
it('middle-click closes tab', function()
command('tabnew')
command('tabnew')
command('tabnew')
command('tabprev')
eq({ 3, 4 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
api.nvim_input_mouse('middle', 'press', '', 0, 0, 1)
eq({ 2, 3 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
api.nvim_input_mouse('middle', 'press', '', 0, 0, 20)
eq({ 2, 2 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
api.nvim_input_mouse('middle', 'press', '', 0, 0, 1)
eq({ 1, 1 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
end)
end)
|