blob: 4d2fca140dc1f30259fc53160f5d9202edd0c7f1 [file] [log] [blame]
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +02001" Tests for tabpanel
2
3source check.vim
4source screendump.vim
5CheckFeature tabpanel
6
Hirohito Higashic659e4a2025-05-16 19:34:34 +02007function s:reset()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +02008 set tabpanel&
9 set tabpanelopt&
10 set showtabpanel&
11endfunc
12
Hirohito Higashif5aa2692025-06-15 16:09:22 +020013function Test_tabpanel_showtabpanel_eq_0()
14 CheckScreendump
15
16 let lines =<< trim END
17 set showtabpanel=2
18 set noruler
19 call setbufline(bufnr(), 1, ['aaa','bbb','ccc','ddd'])
20 tabnew 0000
21 END
22 call writefile(lines, 'XTest_tabpanel_stpl_eq_0', 'D')
23
24 let buf = RunVimInTerminal('-S XTest_tabpanel_stpl_eq_0', {'rows': 10, 'cols': 78})
25 call term_sendkeys(buf, ":set showtabpanel=0\<CR>\<C-L>")
26 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_0', {})
27 call term_sendkeys(buf, ":tabnext\<CR>\<C-L>")
28 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_1', {})
Hirohito Higashiacd04b22025-06-16 20:26:08 +020029 call term_sendkeys(buf, ":set showtabpanel=2\<CR>")
30 call term_sendkeys(buf, ":vsp aaa\<CR>:vsp bbb\<CR>\<C-L>")
31 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_2', {})
32 call term_sendkeys(buf, ":set showtabpanel=0\<CR>\<C-L>")
33 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_3', {})
34 call term_sendkeys(buf, ":wincmd |\<CR>")
35 call term_sendkeys(buf, ":set showtabpanel=2\<CR>\<C-L>")
36 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_2', {})
Hirohito Higashif5aa2692025-06-15 16:09:22 +020037 call StopVimInTerminal(buf)
38endfunc
39
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +020040function Test_tabpanel_showtabpanel_eq_1()
41 CheckScreendump
42
43 let lines =<< trim END
44 set showtabpanel=1
45 set noruler
46 END
47 call writefile(lines, 'XTest_tabpanel_stpl_eq_1', 'D')
48
49 let buf = RunVimInTerminal('-S XTest_tabpanel_stpl_eq_1', {'rows': 10, 'cols': 78})
50 call term_sendkeys(buf, "\<C-L>")
51 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
52 call term_sendkeys(buf, ":tabnew\<CR>\<C-L>")
53 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_1', {})
54 call term_sendkeys(buf, ":tabfirst\<CR>:vsplit\<CR>\<C-L>")
55 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_2', {})
56 call term_sendkeys(buf, ":tabclose\<CR>\<C-L>")
57 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
58
59 call term_sendkeys(buf, ":set tabpanelopt=align:right\<CR>\<C-L>")
60 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
61 call term_sendkeys(buf, ":tabnew\<CR>\<C-L>")
62 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_3', {})
63 call term_sendkeys(buf, ":tabfirst\<CR>:vsplit\<CR>\<C-L>")
64 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_4', {})
65 call term_sendkeys(buf, ":tabclose\<CR>\<C-L>")
66 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
67 call StopVimInTerminal(buf)
68endfunc
69
70function Test_tabpanel_with_vsplit()
71 CheckScreendump
72
73 let lines =<< trim END
74 set showtabpanel=2
75 set tabpanelopt=columns:20
76 set showtabline=0
77 tabnew
78 END
79 call writefile(lines, 'XTest_tabpanel_with_vsplit', 'D')
80
81 let buf = RunVimInTerminal('-S XTest_tabpanel_with_vsplit', {'rows': 10, 'cols': 78})
82 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_0', {})
83 call term_sendkeys(buf, ":vsplit\<CR>")
84 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_1', {})
85 call term_sendkeys(buf, ":vsplit\<CR>")
86 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_2', {})
87
88 call term_sendkeys(buf, ":only\<CR>")
89 call term_sendkeys(buf, ":set tabpanelopt=align:right,vert\<CR>")
90 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_3', {})
91 call term_sendkeys(buf, ":vsplit\<CR>")
92 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_4', {})
93 call term_sendkeys(buf, ":vsplit\<CR>")
94 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_5', {})
95 call StopVimInTerminal(buf)
96endfunc
97
Hirohito Higashic659e4a2025-05-16 19:34:34 +020098function Test_tabpanel_mouse()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +020099 let save_showtabline = &showtabline
100 let save_mouse = &mouse
101 set showtabline=0 mouse=a
102
103 tabnew
104 tabnew
105
106 call test_setmouse(1, 1)
107 call feedkeys("\<LeftMouse>", 'xt')
108 call assert_equal(3, tabpagenr())
109
110 set showtabpanel=2 tabpanelopt=columns:10
111
112 call test_setmouse(1, 1)
113 call feedkeys("\<LeftMouse>", 'xt')
114 call assert_equal(1, tabpagenr())
115 call test_setmouse(2, 1)
116 call feedkeys("\<LeftMouse>", 'xt')
117 call assert_equal(2, tabpagenr())
118 call test_setmouse(3, 1)
119 call feedkeys("\<LeftMouse>", 'xt')
120 call assert_equal(3, tabpagenr())
121
Hirohito Higashia1522f72025-06-03 21:07:25 +0200122 " Confirm that tabpagenr() does not change when dragging outside the tabpanel
123 call test_setmouse(3, 30)
124 call feedkeys("\<LeftMouse>", 'xt')
125 call test_setmouse(1, 30)
126 call feedkeys("\<LeftDrag>", 'xt')
127 call assert_equal(3, tabpagenr())
128
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200129 call feedkeys("\<LeftMouse>", 'xt')
130 call test_setmouse(2, 3)
131 let pos = getmousepos()
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200132 call assert_equal(0, pos['winid'])
133 call assert_equal(0, pos['winrow'])
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200134 call assert_equal(0, pos['wincol'])
135 call assert_equal(2, pos['screenrow'])
136 call assert_equal(3, pos['screencol'])
137
138 call test_setmouse(1, 11)
139 call feedkeys("\<LeftMouse>", 'xt')
140 let pos = getmousepos()
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200141 call assert_notequal(0, pos['winid'])
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200142 call assert_equal(1, pos['winrow'])
143 call assert_equal(1, pos['wincol'])
144 call assert_equal(1, pos['screenrow'])
145 call assert_equal(11, pos['screencol'])
146
147 new
148 wincmd x
149
150 call test_setmouse(10, 11)
151 call feedkeys("\<LeftMouse>", 'xt')
152 let pos = getmousepos()
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200153 call assert_notequal(0, pos['winid'])
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200154 call assert_equal(10, pos['winrow'])
155 call assert_equal(1, pos['wincol'])
156 call assert_equal(10, pos['screenrow'])
157 call assert_equal(11, pos['screencol'])
158
159 tabonly!
160 call s:reset()
161 let &mouse = save_mouse
162 let &showtabline = save_showtabline
163endfunc
164
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200165function Test_tabpanel_drawing()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200166 CheckScreendump
167
168 let lines =<< trim END
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200169 function MyTabPanel()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200170 let n = g:actual_curtabpage
171 let hi = n == tabpagenr() ? 'TabLineSel' : 'TabLine'
172 let label = printf("\n%%#%sTabNumber#%d:%%#%s#", hi, n, hi)
173 let label ..= '%1*%f%*'
174 return label
175 endfunction
176 hi User1 ctermfg=12
177
178 set showtabline=0
179 set showtabpanel=0
180 set tabpanelopt=columns:16
181 set tabpanel=
182 silent edit Xtabpanel1
183
184 nnoremap \01 <Cmd>set showtabpanel=2<CR>
185 nnoremap \02 <C-w>v
186 nnoremap \03 <Cmd>call setline(1, ['a', 'b', 'c'])<CR>
187 nnoremap \04 <Cmd>silent tabnew Xtabpanel2<CR><Cmd>call setline(1, ['d', 'e', 'f'])<CR>
188 nnoremap \05 <Cmd>set tabpanel=%!MyTabPanel()<CR>
189 nnoremap \06 <Cmd>set tabpanelopt+=align:right<CR>
190 nnoremap \07 <Cmd>tab terminal NONE<CR><C-w>N
191 nnoremap \08 <Cmd>tabclose!<CR><Cmd>tabclose!<CR>
192 END
193 call writefile(lines, 'XTest_tabpanel', 'D')
194
195 let buf = RunVimInTerminal('-S XTest_tabpanel', {'rows': 6, 'cols': 45})
196
197 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_00', {})
198
199 for i in range(1, 8)
200 let n = printf('%02d', i)
201 call term_sendkeys(buf, '\' .. n)
202 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_' .. n, {})
203 endfor
204
205 call StopVimInTerminal(buf)
206endfunc
207
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200208function Test_tabpanel_drawing_with_popupwin()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200209 CheckScreendump
210
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200211 let tcols = 45
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200212 let lines =<< trim END
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200213 set showtabpanel=0
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200214 set tabpanelopt=columns:20
215 set showtabline=0
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200216 set nowrap
217 set noruler
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200218 tabnew
219 setlocal buftype=nofile
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200220 call setbufline(bufnr(), 1, repeat([repeat('.', &columns)], &lines - &ch))
221 for col in [1, &columns - 2]
222 call popup_create(['@'],
223 \ {
224 \ 'line': 1,
225 \ 'col': col,
226 \ 'border': [],
227 \ 'highlight': 'ErrorMsg',
228 \ })
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200229 endfor
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200230 call cursor(5, 10)
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200231 call popup_atcursor('atcursor', {
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200232 \ 'highlight': 'Question',
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200233 \ })
234 END
235 call writefile(lines, 'XTest_tabpanel_with_popupwin', 'D')
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200236 let buf = RunVimInTerminal('-S XTest_tabpanel_with_popupwin', {'rows': 10, 'cols': tcols})
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200237 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_0', {})
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200238 call term_sendkeys(buf, ":set showtabpanel=2\<CR>\<C-L>")
239 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_1', {})
240 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>\<C-L>")
241 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_2', {})
242 call term_sendkeys(buf, ":set showtabpanel=0\<CR>\<C-L>")
243 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_0', {})
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200244 call StopVimInTerminal(buf)
245endfunc
246
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200247function Test_tabpanel_drawing_fill_tailing()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200248 CheckScreendump
249
250 let lines =<< trim END
251 set showtabpanel=2
252 set tabpanelopt=columns:20
253 set showtabline=0
254 e aaa.txt
255 tabnew
256 e bbb.txt
257 let &tabpanel = "abc"
258 redraw!
259 " Check whether "abc" is cleared
260 let &tabpanel = "\nTOP\n%f\nBOTTOM"
261 END
262 call writefile(lines, 'XTest_tabpanel_fill_tailing', 'D')
263
264 let buf = RunVimInTerminal('-S XTest_tabpanel_fill_tailing', {'rows': 10, 'cols': 45})
265
266 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_fill_tailing_0', {})
267
268 call StopVimInTerminal(buf)
269endfunc
270
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200271function Test_tabpanel_drawing_pum()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200272 CheckScreendump
273
274 let lines =<< trim END
275 set showtabpanel=2
276 set tabpanelopt=columns:20
277 set showtabline=0
278 e aaa.txt
279 tabnew
280 e bbb.txt
281 END
282 call writefile(lines, 'XTest_tabpanel_pum', 'D')
283
284 let buf = RunVimInTerminal('-S XTest_tabpanel_pum', {'rows': 10, 'cols': 45})
285
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200286 call term_sendkeys(buf, "i\<CR>aa\<CR>aaaa\<CR>aaac\<CR>aaab\<CR>\<Esc>")
287 call term_sendkeys(buf, "ggi\<C-X>\<C-N>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200288 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_0', {})
289
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200290 call term_sendkeys(buf, "\<Esc>Go a\<C-X>\<C-P>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200291 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_1', {})
292
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200293 call term_sendkeys(buf, "\<C-U>\<CR>\<Esc>")
294 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
295 let num = 45 - 20 - 2 " term-win-width - tabpanel-columns - 2
296 call term_sendkeys(buf, num .. "a \<Esc>")
297 call term_sendkeys(buf, "a\<C-X>\<C-N>")
298 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_2', {})
299
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200300 call StopVimInTerminal(buf)
301endfunc
302
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200303function Test_tabpanel_scrolling()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200304 CheckScreendump
305
306 let lines =<< trim END
307 set showtabpanel=2
308 set tabpanelopt=columns:20
309 set showtabline=0
310 set nowrap
311 set number
312 e aaa.txt
313 tabnew
314 e bbb.txt
315 vsplit
316 call setbufline(bufnr(), 1, repeat(['text text text text'], 100))
317 wincmd =
318 END
319 call writefile(lines, 'XTest_tabpanel_scrolling', 'D')
320
321 let buf = RunVimInTerminal('-S XTest_tabpanel_scrolling', {'rows': 10, 'cols': 45})
322 let n = 0
323 for c in ['H', 'J', 'K', 'L']
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200324 call term_sendkeys(buf, ":wincmd " .. c .. "\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200325 call term_sendkeys(buf, "\<C-d>\<C-d>")
326 call term_sendkeys(buf, "r@")
327 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_scrolling_' .. n, {})
328 let n += 1
329 endfor
330
331 call StopVimInTerminal(buf)
332endfunc
333
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200334function Test_tabpanel_many_tabpages()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200335 CheckScreendump
336
337 let lines =<< trim END
338 set showtabpanel=2
339 set tabpanelopt=columns:10
340 set showtabline=0
341 set tabpanel=%{g:actual_curtabpage}:tab
342 execute join(repeat(['tabnew'], 20), ' | ')
343 END
344 call writefile(lines, 'XTest_tabpanel_many_tabpages', 'D')
345
346 let buf = RunVimInTerminal('-S XTest_tabpanel_many_tabpages', {'rows': 10, 'cols': 45})
347 for n in range(0, 3)
348 call term_sendkeys(buf, "gt")
349 call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_' .. n, {})
350 endfor
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200351 call term_sendkeys(buf, ":tabnext +10\<CR>")
352 call term_sendkeys(buf, ":tabnext -3\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200353 call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_4', {})
354
355 call StopVimInTerminal(buf)
356endfunc
357
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200358function Test_tabpanel_visual()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200359 CheckScreendump
360
361 let lines =<< trim END
362 set showtabpanel=2
363 set tabpanelopt=columns:10
364 set showtabline=0
365 tabnew
366 call setbufline(bufnr(), 1, ['aaa1 bbb1 ccc1 ddd1', 'aaa2 bbb2 ccc2 ddd2', 'aaa3 bbb3 ccc3 ddd3', 'aaa4 bbb4 ccc4 ddd4'])
367 END
368 call writefile(lines, 'XTest_tabpanel_visual', 'D')
369
370 let buf = RunVimInTerminal('-S XTest_tabpanel_visual', {'rows': 10, 'cols': 45})
371 call term_sendkeys(buf, "v2w")
372 call VerifyScreenDump(buf, 'Test_tabpanel_visual_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200373 call term_sendkeys(buf, "\<Esc>0jw")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200374 call term_sendkeys(buf, "v2wge")
375 call VerifyScreenDump(buf, 'Test_tabpanel_visual_1', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200376 call term_sendkeys(buf, "y:echo @\"\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200377 call VerifyScreenDump(buf, 'Test_tabpanel_visual_2', {})
378
379 call StopVimInTerminal(buf)
380endfunc
381
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200382function Test_tabpanel_commandline()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200383 CheckScreendump
384
385 let lines =<< trim END
386 set showtabpanel=2
387 set tabpanelopt=columns:10
388 set showtabline=0
389 tabnew
390 END
391 call writefile(lines, 'XTest_tabpanel_commandline', 'D')
392
393 let buf = RunVimInTerminal('-S XTest_tabpanel_commandline', {'rows': 10, 'cols': 45})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200394 call term_sendkeys(buf, ":ab\<Tab>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200395 call VerifyScreenDump(buf, 'Test_tabpanel_commandline_0', {})
396
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200397 call term_sendkeys(buf, "\<Esc>")
398 call term_sendkeys(buf, ":set wildoptions=pum\<CR>")
399 call term_sendkeys(buf, ":ab\<Tab>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200400 call VerifyScreenDump(buf, 'Test_tabpanel_commandline_1', {})
401
402 call StopVimInTerminal(buf)
403endfunc
404
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200405function Test_tabpanel_tabline_and_tabpanel()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200406 CheckScreendump
407
408 let lines =<< trim END
409 set showtabpanel=2
410 set tabpanelopt=columns:10,vert
411 set fillchars=tpl_vert:│
412 set showtabline=2
413 e aaa.txt
414 tabnew
415 e bbb.txt
416 tabnew
417 e ccc.txt
418 END
419 call writefile(lines, 'XTest_tabpanel_tabline_and_tabpanel', 'D')
420
421 let buf = RunVimInTerminal('-S XTest_tabpanel_tabline_and_tabpanel', {'rows': 10, 'cols': 45})
422 call VerifyScreenDump(buf, 'Test_tabpanel_tabline_and_tabpanel_0', {})
423
424 call StopVimInTerminal(buf)
425endfunc
426
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200427function Test_tabpanel_dont_overflow_into_tabpanel()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200428 CheckScreendump
429
430 let lines =<< trim END
431 set showtabpanel=2
432 set tabpanelopt=columns:10
433 set showtabline=2
434 tabnew
435 call setline(1, repeat('x', 100))
436 set wrap
437 END
438 call writefile(lines, 'XTest_tabpanel_dont_overflow_into_tabpanel', 'D')
439
440 let buf = RunVimInTerminal('-S XTest_tabpanel_dont_overflow_into_tabpanel', {'rows': 10, 'cols': 45})
441 call VerifyScreenDump(buf, 'Test_tabpanel_dont_overflow_into_tabpanel_0', {})
442
443 call StopVimInTerminal(buf)
444endfunc
445
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200446"""function Test_tabpanel_dont_vert_is_multibytes_left()
447""" CheckScreendump
448"""
449""" let lines =<< trim END
450""" set showtabpanel=2
451""" set tabpanelopt=columns:10,vert
452""" set fillchars=tpl_vert:│
453""" set showtabline=2
454""" tabnew
455""" END
456""" call writefile(lines, 'XTest_tabpanel_vert_is_multibyte_lefts', 'D')
457"""
458""" let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibyte_lefts', {'rows': 10, 'cols': 45})
459""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_0', {})
460"""
461""" call term_sendkeys(buf, ":set tabpanelopt=columns:1,vert\<CR>")
462""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_1', {})
463"""
464""" call term_sendkeys(buf, ":set tabpanelopt=columns:10,vert\<CR>")
465""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_2', {})
466"""
467""" call term_sendkeys(buf, ":set tabpanelopt=columns:2,vert\<CR>")
468""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_3', {})
469"""
470""" call StopVimInTerminal(buf)
471"""endfunc
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200472
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200473"""function Test_tabpanel_dont_vert_is_multibytes_right()
474""" CheckScreendump
475"""
476""" let lines =<< trim END
477""" set showtabpanel=2
478""" set tabpanelopt=align:right,columns:10,vert
479""" set fillchars=tpl_vert:│
480""" set showtabline=2
481""" tabnew
482""" END
483""" call writefile(lines, 'XTest_tabpanel_vert_is_multibytes_right', 'D')
484"""
485""" let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibytes_right', {'rows': 10, 'cols': 45})
486""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_0', {})
487"""
488""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:1,vert\<CR>")
489""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_1', {})
490"""
491""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:10,vert\<CR>")
492""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_2', {})
493"""
494""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:2,vert\<CR>")
495""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_3', {})
496"""
497""" call StopVimInTerminal(buf)
498"""endfunc
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200499
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200500function Test_tabpanel_eval_tabpanel_statusline_tabline()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200501 CheckScreendump
502
503 let lines =<< trim END
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200504 function Expr()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200505 return "$%=[%f]%=$"
506 endfunction
507 set laststatus=2
508 set showtabline=2
509 set showtabpanel=2
510 set statusline=%!Expr()
511 set tabline=%!Expr()
512 set tabpanel=%!Expr()
513 set tabpanelopt=columns:10,vert
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200514 e aaa
515 tabnew
516 e bbb
517 tabnew
518 e ccc
519 END
520 call writefile(lines, 'XTest_tabpanel_eval_tabpanel_statusline_tabline', 'D')
521
522 let buf = RunVimInTerminal('-S XTest_tabpanel_eval_tabpanel_statusline_tabline', {'rows': 10, 'cols': 45})
523 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_statusline_tabline_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200524 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200525 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_statusline_tabline_1', {})
526
527 call StopVimInTerminal(buf)
528endfunc
529
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200530function Test_tabpanel_noeval_tabpanel_statusline_tabline()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200531 CheckScreendump
532
533 let lines =<< trim END
534 set laststatus=2
535 set showtabline=2
536 set showtabpanel=2
537 set statusline=$%=[%f]%=$
538 set tabline=$%=[%f]%=$
539 set tabpanel=$%=[%f]%=$
540 set tabpanelopt=columns:10,vert
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200541 e aaa
542 tabnew
543 e bbb
544 tabnew
545 e ccc
546 END
547 call writefile(lines, 'XTest_tabpanel_noeval_tabpanel_statusline_tabline', 'D')
548
549 let buf = RunVimInTerminal('-S XTest_tabpanel_noeval_tabpanel_statusline_tabline', {'rows': 10, 'cols': 45})
550 call VerifyScreenDump(buf, 'Test_tabpanel_noeval_tabpanel_statusline_tabline_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200551 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200552 call VerifyScreenDump(buf, 'Test_tabpanel_noeval_tabpanel_statusline_tabline_1', {})
553
554 call StopVimInTerminal(buf)
555endfunc
556
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200557function Test_tabpanel_eval_tabpanel_with_linebreaks()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200558 CheckScreendump
559
560 let lines =<< trim END
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200561 function Expr()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200562 return "top\n$%=[%f]%=$\nbottom"
563 endfunction
564 set showtabpanel=2
565 set tabpanel=%!Expr()
566 set tabpanelopt=columns:10
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200567 set noruler
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200568 e aaa
569 tabnew
570 e bbb
571 tabnew
572 e ccc
573 END
574 call writefile(lines, 'XTest_tabpanel_eval_tabpanel_with_linebreaks', 'D')
575
576 let buf = RunVimInTerminal('-S XTest_tabpanel_eval_tabpanel_with_linebreaks', {'rows': 10, 'cols': 45})
577 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_with_linebreaks_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200578 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200579 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_with_linebreaks_1', {})
580
581 call StopVimInTerminal(buf)
582endfunc
583
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200584function Test_tabpanel_tabonly()
585 CheckScreendump
586
587 let lines =<< trim END
588 tabnew
589 set showtabpanel=1
590 norm 100oasdf
591 vsplit
592 END
593 call writefile(lines, 'XTest_tabpanel_tabonly', 'D')
594
Christian Brabandta004e512025-05-26 19:54:07 +0200595 let buf = RunVimInTerminal('-S XTest_tabpanel_tabonly', {'rows': 10, 'cols': 78})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200596 call VerifyScreenDump(buf, 'Test_tabpanel_only_0', {})
597 call term_sendkeys(buf, ":tabonly\<CR>")
598 call VerifyScreenDump(buf, 'Test_tabpanel_only_1', {})
599
600 call StopVimInTerminal(buf)
601endfunc
602
Naruhiko Nishino2a1e2532025-05-17 16:19:24 +0200603function Test_tabpanel_equalalways()
604 CheckScreendump
605
606 let lines =<< trim END
607 tabnew
608 set showtabpanel=1
609 set tabpanelopt=columns:20
610 set equalalways
611 split
612 vsplit
613 END
614 call writefile(lines, 'XTest_tabpanel_equalalways', 'D')
615
616 let buf = RunVimInTerminal('-S XTest_tabpanel_equalalways', {'rows': 10, 'cols': 78})
617 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_0', {})
618 call term_sendkeys(buf, ":set tabpanelopt=columns:10\<CR>")
619 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_1', {})
620 call term_sendkeys(buf, ":set tabpanelopt=columns:30\<CR>")
621 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_2', {})
622 call term_sendkeys(buf, ":set tabpanelopt=columns:5\<CR>")
623 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_3', {})
624
625 call StopVimInTerminal(buf)
626endfunc
627
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200628function Test_tabpanel_quitall()
629 CheckScreendump
630
631 let lines =<< trim END
632 tabnew
633 set showtabpanel=1
634 set laststatus=2
635 call setline(1, 'aaa')
636 normal gt
637 silent! quitall
638 END
639 call writefile(lines, 'XTest_tabpanel_quitall', 'D')
640
641 let buf = RunVimInTerminal('-S XTest_tabpanel_quitall', {'rows': 10, 'cols': 45})
642 call VerifyScreenDump(buf, 'Test_tabpanel_quitall_0', {})
643
644 call StopVimInTerminal(buf)
645endfunc
646
647function Test_tabpanel_ruler()
648 CheckScreendump
649
650 let lines =<< trim END
651 tabnew
652 set statusline& laststatus=0
653 set rulerformat& ruler
654 set showtabpanel=1
655 END
656 call writefile(lines, 'XTest_tabpanel_ruler', 'D')
657
658 let buf = RunVimInTerminal('-S XTest_tabpanel_ruler', {'rows': 10, 'cols': 45})
659 call VerifyScreenDump(buf, 'Test_tabpanel_ruler_0', {})
660
661 call StopVimInTerminal(buf)
662endfunc
663
Christian Brabandta88c5bd2025-05-26 19:51:03 +0200664function Test_tabpanel_error()
665 set tabpanel=%!NonExistingFunc()
666 try
667 set showtabpanel=2
668 redraw!
669 catch /^Vim\%((\a\+)\)\=:E117:/
670 endtry
671 call assert_true(empty(&tabpanel))
Christian Brabandtac83b3c2025-05-27 20:49:34 +0200672
673 try
674 set tabpanel=%{my#util#TabPanelHighlight}%t
675 redraw!
676 catch /^Vim\%((\a\+)\)\=:E121:/
677 endtry
678 call assert_true(empty(&tabpanel))
679
Christian Brabandta88c5bd2025-05-26 19:51:03 +0200680 set tabpanel&vim
681 set showtabpanel&vim
682endfunc
Hirohito Higashi3ca67762025-06-10 20:19:04 +0200683
684function Test_tabpanel_with_msg_scrolled()
685 CheckScreendump
686
687 let lines =<< trim END
688 set showtabpanel=2
689 set noruler
690 tabnew
691 set modified
692 tabfirst
693 END
694 call writefile(lines, 'XTest_tabpanel_with_msg_scrolled', 'D')
695
696 let buf = RunVimInTerminal('-S XTest_tabpanel_with_msg_scrolled', {'rows': 10, 'cols': 45})
697 call VerifyScreenDump(buf, 'Test_tabpanel_with_msg_scrolled_0', {})
698 call term_sendkeys(buf, ":qa\<CR>")
699 call term_sendkeys(buf, "\<CR>")
700 call VerifyScreenDump(buf, 'Test_tabpanel_with_msg_scrolled_1', {})
701
702 call StopVimInTerminal(buf)
703endfunc
Hirohito Higashie5c96e32025-06-16 19:39:24 +0200704
705function Test_tabpanel_with_cmdline_pum()
706 CheckScreendump
707
708 let lines =<< trim END
709 set showtabpanel=2
710 set noruler
711 tabnew aaa
712 set wildoptions+=pum
713 func TimerCb(timer)
714 tabnew bbb
715 endfunc
716 call timer_start(100, 'TimerCb')
717 END
718 call writefile(lines, 'XTest_tabpanel_with_cmdline_pum', 'D')
719
720 let buf = RunVimInTerminal('-S XTest_tabpanel_with_cmdline_pum', {'rows': 10, 'cols': 45})
721 call term_sendkeys(buf, "\<C-L>")
722 call VerifyScreenDump(buf, 'Test_tabpanel_with_cmdline_pum_0', {})
723 call term_sendkeys(buf, ":set\<Tab>")
724 call term_wait(buf, 120)
725 call VerifyScreenDump(buf, 'Test_tabpanel_with_cmdline_pum_1', {})
726 call term_sendkeys(buf, "\<Esc>:tabclose\<CR>\<C-L>")
727 call VerifyScreenDump(buf, 'Test_tabpanel_with_cmdline_pum_0', {})
728
729 call StopVimInTerminal(buf)
730endfunc
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200731" vim: shiftwidth=2 sts=2 expandtab