blob: f2925504c41b9b679dd33dd4c6eb569a505a8a56 [file] [log] [blame]
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +02001" Tests for tabpanel
2
Christian Brabandteb380b92025-07-07 20:53:55 +02003source util/screendump.vim
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +02004CheckFeature tabpanel
5
Hirohito Higashic659e4a2025-05-16 19:34:34 +02006function s:reset()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +02007 set tabpanel&
8 set tabpanelopt&
9 set showtabpanel&
10endfunc
11
Hirohito Higashif5aa2692025-06-15 16:09:22 +020012function Test_tabpanel_showtabpanel_eq_0()
13 CheckScreendump
14
15 let lines =<< trim END
16 set showtabpanel=2
17 set noruler
18 call setbufline(bufnr(), 1, ['aaa','bbb','ccc','ddd'])
19 tabnew 0000
20 END
21 call writefile(lines, 'XTest_tabpanel_stpl_eq_0', 'D')
22
23 let buf = RunVimInTerminal('-S XTest_tabpanel_stpl_eq_0', {'rows': 10, 'cols': 78})
24 call term_sendkeys(buf, ":set showtabpanel=0\<CR>\<C-L>")
25 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_0', {})
26 call term_sendkeys(buf, ":tabnext\<CR>\<C-L>")
27 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_1', {})
Hirohito Higashiacd04b22025-06-16 20:26:08 +020028 call term_sendkeys(buf, ":set showtabpanel=2\<CR>")
29 call term_sendkeys(buf, ":vsp aaa\<CR>:vsp bbb\<CR>\<C-L>")
30 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_2', {})
31 call term_sendkeys(buf, ":set showtabpanel=0\<CR>\<C-L>")
32 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_3', {})
33 call term_sendkeys(buf, ":wincmd |\<CR>")
34 call term_sendkeys(buf, ":set showtabpanel=2\<CR>\<C-L>")
35 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_2', {})
Hirohito Higashif5aa2692025-06-15 16:09:22 +020036 call StopVimInTerminal(buf)
37endfunc
38
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +020039function Test_tabpanel_showtabpanel_eq_1()
40 CheckScreendump
41
42 let lines =<< trim END
43 set showtabpanel=1
44 set noruler
45 END
46 call writefile(lines, 'XTest_tabpanel_stpl_eq_1', 'D')
47
48 let buf = RunVimInTerminal('-S XTest_tabpanel_stpl_eq_1', {'rows': 10, 'cols': 78})
49 call term_sendkeys(buf, "\<C-L>")
50 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
51 call term_sendkeys(buf, ":tabnew\<CR>\<C-L>")
52 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_1', {})
53 call term_sendkeys(buf, ":tabfirst\<CR>:vsplit\<CR>\<C-L>")
54 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_2', {})
55 call term_sendkeys(buf, ":tabclose\<CR>\<C-L>")
56 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
57
58 call term_sendkeys(buf, ":set tabpanelopt=align:right\<CR>\<C-L>")
59 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
60 call term_sendkeys(buf, ":tabnew\<CR>\<C-L>")
61 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_3', {})
62 call term_sendkeys(buf, ":tabfirst\<CR>:vsplit\<CR>\<C-L>")
63 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_4', {})
64 call term_sendkeys(buf, ":tabclose\<CR>\<C-L>")
65 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
66 call StopVimInTerminal(buf)
67endfunc
68
69function Test_tabpanel_with_vsplit()
70 CheckScreendump
71
72 let lines =<< trim END
73 set showtabpanel=2
74 set tabpanelopt=columns:20
75 set showtabline=0
76 tabnew
77 END
78 call writefile(lines, 'XTest_tabpanel_with_vsplit', 'D')
79
80 let buf = RunVimInTerminal('-S XTest_tabpanel_with_vsplit', {'rows': 10, 'cols': 78})
81 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_0', {})
82 call term_sendkeys(buf, ":vsplit\<CR>")
83 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_1', {})
84 call term_sendkeys(buf, ":vsplit\<CR>")
85 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_2', {})
86
87 call term_sendkeys(buf, ":only\<CR>")
88 call term_sendkeys(buf, ":set tabpanelopt=align:right,vert\<CR>")
89 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_3', {})
90 call term_sendkeys(buf, ":vsplit\<CR>")
91 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_4', {})
92 call term_sendkeys(buf, ":vsplit\<CR>")
93 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_5', {})
94 call StopVimInTerminal(buf)
95endfunc
96
Hirohito Higashic659e4a2025-05-16 19:34:34 +020097function Test_tabpanel_mouse()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +020098 let save_showtabline = &showtabline
99 let save_mouse = &mouse
100 set showtabline=0 mouse=a
101
102 tabnew
103 tabnew
104
105 call test_setmouse(1, 1)
106 call feedkeys("\<LeftMouse>", 'xt')
107 call assert_equal(3, tabpagenr())
108
109 set showtabpanel=2 tabpanelopt=columns:10
110
111 call test_setmouse(1, 1)
112 call feedkeys("\<LeftMouse>", 'xt')
113 call assert_equal(1, tabpagenr())
114 call test_setmouse(2, 1)
115 call feedkeys("\<LeftMouse>", 'xt')
116 call assert_equal(2, tabpagenr())
117 call test_setmouse(3, 1)
118 call feedkeys("\<LeftMouse>", 'xt')
119 call assert_equal(3, tabpagenr())
120
Hirohito Higashia1522f72025-06-03 21:07:25 +0200121 " Confirm that tabpagenr() does not change when dragging outside the tabpanel
122 call test_setmouse(3, 30)
123 call feedkeys("\<LeftMouse>", 'xt')
124 call test_setmouse(1, 30)
125 call feedkeys("\<LeftDrag>", 'xt')
126 call assert_equal(3, tabpagenr())
127
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200128 call feedkeys("\<LeftMouse>", 'xt')
129 call test_setmouse(2, 3)
130 let pos = getmousepos()
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200131 call assert_equal(0, pos['winid'])
132 call assert_equal(0, pos['winrow'])
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200133 call assert_equal(0, pos['wincol'])
134 call assert_equal(2, pos['screenrow'])
135 call assert_equal(3, pos['screencol'])
136
137 call test_setmouse(1, 11)
138 call feedkeys("\<LeftMouse>", 'xt')
139 let pos = getmousepos()
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200140 call assert_notequal(0, pos['winid'])
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200141 call assert_equal(1, pos['winrow'])
142 call assert_equal(1, pos['wincol'])
143 call assert_equal(1, pos['screenrow'])
144 call assert_equal(11, pos['screencol'])
145
146 new
147 wincmd x
148
149 call test_setmouse(10, 11)
150 call feedkeys("\<LeftMouse>", 'xt')
151 let pos = getmousepos()
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200152 call assert_notequal(0, pos['winid'])
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200153 call assert_equal(10, pos['winrow'])
154 call assert_equal(1, pos['wincol'])
155 call assert_equal(10, pos['screenrow'])
156 call assert_equal(11, pos['screencol'])
157
158 tabonly!
159 call s:reset()
160 let &mouse = save_mouse
161 let &showtabline = save_showtabline
162endfunc
163
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200164function Test_tabpanel_drawing()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200165 CheckScreendump
166
167 let lines =<< trim END
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200168 function MyTabPanel()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200169 let n = g:actual_curtabpage
170 let hi = n == tabpagenr() ? 'TabLineSel' : 'TabLine'
171 let label = printf("\n%%#%sTabNumber#%d:%%#%s#", hi, n, hi)
172 let label ..= '%1*%f%*'
173 return label
174 endfunction
175 hi User1 ctermfg=12
176
177 set showtabline=0
178 set showtabpanel=0
179 set tabpanelopt=columns:16
180 set tabpanel=
181 silent edit Xtabpanel1
182
183 nnoremap \01 <Cmd>set showtabpanel=2<CR>
184 nnoremap \02 <C-w>v
185 nnoremap \03 <Cmd>call setline(1, ['a', 'b', 'c'])<CR>
186 nnoremap \04 <Cmd>silent tabnew Xtabpanel2<CR><Cmd>call setline(1, ['d', 'e', 'f'])<CR>
187 nnoremap \05 <Cmd>set tabpanel=%!MyTabPanel()<CR>
188 nnoremap \06 <Cmd>set tabpanelopt+=align:right<CR>
189 nnoremap \07 <Cmd>tab terminal NONE<CR><C-w>N
190 nnoremap \08 <Cmd>tabclose!<CR><Cmd>tabclose!<CR>
191 END
192 call writefile(lines, 'XTest_tabpanel', 'D')
193
194 let buf = RunVimInTerminal('-S XTest_tabpanel', {'rows': 6, 'cols': 45})
195
196 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_00', {})
197
198 for i in range(1, 8)
199 let n = printf('%02d', i)
200 call term_sendkeys(buf, '\' .. n)
201 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_' .. n, {})
202 endfor
203
204 call StopVimInTerminal(buf)
205endfunc
206
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200207function Test_tabpanel_drawing_with_popupwin()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200208 CheckScreendump
209
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200210 let tcols = 45
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200211 let lines =<< trim END
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200212 set showtabpanel=0
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200213 set tabpanelopt=columns:20
214 set showtabline=0
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200215 set nowrap
216 set noruler
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200217 tabnew
218 setlocal buftype=nofile
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200219 call setbufline(bufnr(), 1, repeat([repeat('.', &columns)], &lines - &ch))
220 for col in [1, &columns - 2]
221 call popup_create(['@'],
222 \ {
223 \ 'line': 1,
224 \ 'col': col,
225 \ 'border': [],
226 \ 'highlight': 'ErrorMsg',
227 \ })
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200228 endfor
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200229 call cursor(5, 10)
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200230 call popup_atcursor('atcursor', {
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200231 \ 'highlight': 'Question',
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200232 \ })
233 END
234 call writefile(lines, 'XTest_tabpanel_with_popupwin', 'D')
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200235 let buf = RunVimInTerminal('-S XTest_tabpanel_with_popupwin', {'rows': 10, 'cols': tcols})
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200236 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_0', {})
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200237 call term_sendkeys(buf, ":set showtabpanel=2\<CR>\<C-L>")
238 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_1', {})
239 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>\<C-L>")
240 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_2', {})
241 call term_sendkeys(buf, ":set showtabpanel=0\<CR>\<C-L>")
242 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_0', {})
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200243 call StopVimInTerminal(buf)
244endfunc
245
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200246function Test_tabpanel_drawing_fill_tailing()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200247 CheckScreendump
248
249 let lines =<< trim END
250 set showtabpanel=2
251 set tabpanelopt=columns:20
252 set showtabline=0
253 e aaa.txt
254 tabnew
255 e bbb.txt
256 let &tabpanel = "abc"
257 redraw!
258 " Check whether "abc" is cleared
259 let &tabpanel = "\nTOP\n%f\nBOTTOM"
260 END
261 call writefile(lines, 'XTest_tabpanel_fill_tailing', 'D')
262
263 let buf = RunVimInTerminal('-S XTest_tabpanel_fill_tailing', {'rows': 10, 'cols': 45})
264
265 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_fill_tailing_0', {})
266
267 call StopVimInTerminal(buf)
268endfunc
269
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200270function Test_tabpanel_drawing_pum()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200271 CheckScreendump
272
273 let lines =<< trim END
274 set showtabpanel=2
275 set tabpanelopt=columns:20
276 set showtabline=0
277 e aaa.txt
278 tabnew
279 e bbb.txt
280 END
281 call writefile(lines, 'XTest_tabpanel_pum', 'D')
282
283 let buf = RunVimInTerminal('-S XTest_tabpanel_pum', {'rows': 10, 'cols': 45})
284
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200285 call term_sendkeys(buf, "i\<CR>aa\<CR>aaaa\<CR>aaac\<CR>aaab\<CR>\<Esc>")
286 call term_sendkeys(buf, "ggi\<C-X>\<C-N>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200287 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_0', {})
288
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200289 call term_sendkeys(buf, "\<Esc>Go a\<C-X>\<C-P>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200290 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_1', {})
291
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200292 call term_sendkeys(buf, "\<C-U>\<CR>\<Esc>")
293 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
294 let num = 45 - 20 - 2 " term-win-width - tabpanel-columns - 2
295 call term_sendkeys(buf, num .. "a \<Esc>")
296 call term_sendkeys(buf, "a\<C-X>\<C-N>")
297 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_2', {})
298
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200299 call StopVimInTerminal(buf)
300endfunc
301
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200302function Test_tabpanel_scrolling()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200303 CheckScreendump
304
305 let lines =<< trim END
306 set showtabpanel=2
307 set tabpanelopt=columns:20
308 set showtabline=0
309 set nowrap
310 set number
311 e aaa.txt
312 tabnew
313 e bbb.txt
314 vsplit
315 call setbufline(bufnr(), 1, repeat(['text text text text'], 100))
316 wincmd =
317 END
318 call writefile(lines, 'XTest_tabpanel_scrolling', 'D')
319
320 let buf = RunVimInTerminal('-S XTest_tabpanel_scrolling', {'rows': 10, 'cols': 45})
321 let n = 0
322 for c in ['H', 'J', 'K', 'L']
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200323 call term_sendkeys(buf, ":wincmd " .. c .. "\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200324 call term_sendkeys(buf, "\<C-d>\<C-d>")
325 call term_sendkeys(buf, "r@")
326 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_scrolling_' .. n, {})
327 let n += 1
328 endfor
329
330 call StopVimInTerminal(buf)
331endfunc
332
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200333function Test_tabpanel_many_tabpages()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200334 CheckScreendump
335
336 let lines =<< trim END
337 set showtabpanel=2
338 set tabpanelopt=columns:10
339 set showtabline=0
340 set tabpanel=%{g:actual_curtabpage}:tab
341 execute join(repeat(['tabnew'], 20), ' | ')
342 END
343 call writefile(lines, 'XTest_tabpanel_many_tabpages', 'D')
344
345 let buf = RunVimInTerminal('-S XTest_tabpanel_many_tabpages', {'rows': 10, 'cols': 45})
346 for n in range(0, 3)
347 call term_sendkeys(buf, "gt")
348 call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_' .. n, {})
349 endfor
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200350 call term_sendkeys(buf, ":tabnext +10\<CR>")
351 call term_sendkeys(buf, ":tabnext -3\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200352 call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_4', {})
353
354 call StopVimInTerminal(buf)
355endfunc
356
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200357function Test_tabpanel_visual()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200358 CheckScreendump
359
360 let lines =<< trim END
361 set showtabpanel=2
362 set tabpanelopt=columns:10
363 set showtabline=0
364 tabnew
365 call setbufline(bufnr(), 1, ['aaa1 bbb1 ccc1 ddd1', 'aaa2 bbb2 ccc2 ddd2', 'aaa3 bbb3 ccc3 ddd3', 'aaa4 bbb4 ccc4 ddd4'])
366 END
367 call writefile(lines, 'XTest_tabpanel_visual', 'D')
368
369 let buf = RunVimInTerminal('-S XTest_tabpanel_visual', {'rows': 10, 'cols': 45})
370 call term_sendkeys(buf, "v2w")
371 call VerifyScreenDump(buf, 'Test_tabpanel_visual_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200372 call term_sendkeys(buf, "\<Esc>0jw")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200373 call term_sendkeys(buf, "v2wge")
374 call VerifyScreenDump(buf, 'Test_tabpanel_visual_1', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200375 call term_sendkeys(buf, "y:echo @\"\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200376 call VerifyScreenDump(buf, 'Test_tabpanel_visual_2', {})
377
378 call StopVimInTerminal(buf)
379endfunc
380
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200381function Test_tabpanel_commandline()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200382 CheckScreendump
383
384 let lines =<< trim END
385 set showtabpanel=2
386 set tabpanelopt=columns:10
387 set showtabline=0
388 tabnew
389 END
390 call writefile(lines, 'XTest_tabpanel_commandline', 'D')
391
392 let buf = RunVimInTerminal('-S XTest_tabpanel_commandline', {'rows': 10, 'cols': 45})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200393 call term_sendkeys(buf, ":ab\<Tab>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200394 call VerifyScreenDump(buf, 'Test_tabpanel_commandline_0', {})
395
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200396 call term_sendkeys(buf, "\<Esc>")
397 call term_sendkeys(buf, ":set wildoptions=pum\<CR>")
398 call term_sendkeys(buf, ":ab\<Tab>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200399 call VerifyScreenDump(buf, 'Test_tabpanel_commandline_1', {})
400
401 call StopVimInTerminal(buf)
402endfunc
403
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200404function Test_tabpanel_tabline_and_tabpanel()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200405 CheckScreendump
406
407 let lines =<< trim END
408 set showtabpanel=2
409 set tabpanelopt=columns:10,vert
410 set fillchars=tpl_vert:│
411 set showtabline=2
412 e aaa.txt
413 tabnew
414 e bbb.txt
415 tabnew
416 e ccc.txt
417 END
418 call writefile(lines, 'XTest_tabpanel_tabline_and_tabpanel', 'D')
419
420 let buf = RunVimInTerminal('-S XTest_tabpanel_tabline_and_tabpanel', {'rows': 10, 'cols': 45})
421 call VerifyScreenDump(buf, 'Test_tabpanel_tabline_and_tabpanel_0', {})
422
423 call StopVimInTerminal(buf)
424endfunc
425
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200426function Test_tabpanel_dont_overflow_into_tabpanel()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200427 CheckScreendump
428
429 let lines =<< trim END
430 set showtabpanel=2
431 set tabpanelopt=columns:10
432 set showtabline=2
433 tabnew
434 call setline(1, repeat('x', 100))
435 set wrap
436 END
437 call writefile(lines, 'XTest_tabpanel_dont_overflow_into_tabpanel', 'D')
438
439 let buf = RunVimInTerminal('-S XTest_tabpanel_dont_overflow_into_tabpanel', {'rows': 10, 'cols': 45})
440 call VerifyScreenDump(buf, 'Test_tabpanel_dont_overflow_into_tabpanel_0', {})
441
442 call StopVimInTerminal(buf)
443endfunc
444
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200445"""function Test_tabpanel_dont_vert_is_multibytes_left()
446""" CheckScreendump
447"""
448""" let lines =<< trim END
449""" set showtabpanel=2
450""" set tabpanelopt=columns:10,vert
451""" set fillchars=tpl_vert:│
452""" set showtabline=2
453""" tabnew
454""" END
455""" call writefile(lines, 'XTest_tabpanel_vert_is_multibyte_lefts', 'D')
456"""
457""" let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibyte_lefts', {'rows': 10, 'cols': 45})
458""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_0', {})
459"""
460""" call term_sendkeys(buf, ":set tabpanelopt=columns:1,vert\<CR>")
461""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_1', {})
462"""
463""" call term_sendkeys(buf, ":set tabpanelopt=columns:10,vert\<CR>")
464""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_2', {})
465"""
466""" call term_sendkeys(buf, ":set tabpanelopt=columns:2,vert\<CR>")
467""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_3', {})
468"""
469""" call StopVimInTerminal(buf)
470"""endfunc
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200471
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200472"""function Test_tabpanel_dont_vert_is_multibytes_right()
473""" CheckScreendump
474"""
475""" let lines =<< trim END
476""" set showtabpanel=2
477""" set tabpanelopt=align:right,columns:10,vert
478""" set fillchars=tpl_vert:│
479""" set showtabline=2
480""" tabnew
481""" END
482""" call writefile(lines, 'XTest_tabpanel_vert_is_multibytes_right', 'D')
483"""
484""" let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibytes_right', {'rows': 10, 'cols': 45})
485""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_0', {})
486"""
487""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:1,vert\<CR>")
488""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_1', {})
489"""
490""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:10,vert\<CR>")
491""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_2', {})
492"""
493""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:2,vert\<CR>")
494""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_3', {})
495"""
496""" call StopVimInTerminal(buf)
497"""endfunc
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200498
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200499function Test_tabpanel_eval_tabpanel_statusline_tabline()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200500 CheckScreendump
501
502 let lines =<< trim END
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200503 function Expr()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200504 return "$%=[%f]%=$"
505 endfunction
506 set laststatus=2
507 set showtabline=2
508 set showtabpanel=2
509 set statusline=%!Expr()
510 set tabline=%!Expr()
511 set tabpanel=%!Expr()
512 set tabpanelopt=columns:10,vert
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200513 e aaa
514 tabnew
515 e bbb
516 tabnew
517 e ccc
518 END
519 call writefile(lines, 'XTest_tabpanel_eval_tabpanel_statusline_tabline', 'D')
520
521 let buf = RunVimInTerminal('-S XTest_tabpanel_eval_tabpanel_statusline_tabline', {'rows': 10, 'cols': 45})
522 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_statusline_tabline_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200523 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200524 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_statusline_tabline_1', {})
525
526 call StopVimInTerminal(buf)
527endfunc
528
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200529function Test_tabpanel_noeval_tabpanel_statusline_tabline()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200530 CheckScreendump
531
532 let lines =<< trim END
533 set laststatus=2
534 set showtabline=2
535 set showtabpanel=2
536 set statusline=$%=[%f]%=$
537 set tabline=$%=[%f]%=$
538 set tabpanel=$%=[%f]%=$
539 set tabpanelopt=columns:10,vert
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200540 e aaa
541 tabnew
542 e bbb
543 tabnew
544 e ccc
545 END
546 call writefile(lines, 'XTest_tabpanel_noeval_tabpanel_statusline_tabline', 'D')
547
548 let buf = RunVimInTerminal('-S XTest_tabpanel_noeval_tabpanel_statusline_tabline', {'rows': 10, 'cols': 45})
549 call VerifyScreenDump(buf, 'Test_tabpanel_noeval_tabpanel_statusline_tabline_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200550 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200551 call VerifyScreenDump(buf, 'Test_tabpanel_noeval_tabpanel_statusline_tabline_1', {})
552
553 call StopVimInTerminal(buf)
554endfunc
555
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200556function Test_tabpanel_eval_tabpanel_with_linebreaks()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200557 CheckScreendump
558
559 let lines =<< trim END
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200560 function Expr()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200561 return "top\n$%=[%f]%=$\nbottom"
562 endfunction
563 set showtabpanel=2
564 set tabpanel=%!Expr()
565 set tabpanelopt=columns:10
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200566 set noruler
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200567 e aaa
568 tabnew
569 e bbb
570 tabnew
571 e ccc
572 END
573 call writefile(lines, 'XTest_tabpanel_eval_tabpanel_with_linebreaks', 'D')
574
575 let buf = RunVimInTerminal('-S XTest_tabpanel_eval_tabpanel_with_linebreaks', {'rows': 10, 'cols': 45})
576 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_with_linebreaks_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200577 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200578 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_with_linebreaks_1', {})
579
580 call StopVimInTerminal(buf)
581endfunc
582
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200583function Test_tabpanel_tabonly()
584 CheckScreendump
585
586 let lines =<< trim END
587 tabnew
588 set showtabpanel=1
589 norm 100oasdf
590 vsplit
591 END
592 call writefile(lines, 'XTest_tabpanel_tabonly', 'D')
593
Christian Brabandta004e512025-05-26 19:54:07 +0200594 let buf = RunVimInTerminal('-S XTest_tabpanel_tabonly', {'rows': 10, 'cols': 78})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200595 call VerifyScreenDump(buf, 'Test_tabpanel_only_0', {})
596 call term_sendkeys(buf, ":tabonly\<CR>")
597 call VerifyScreenDump(buf, 'Test_tabpanel_only_1', {})
598
599 call StopVimInTerminal(buf)
600endfunc
601
Naruhiko Nishino2a1e2532025-05-17 16:19:24 +0200602function Test_tabpanel_equalalways()
603 CheckScreendump
604
605 let lines =<< trim END
606 tabnew
607 set showtabpanel=1
608 set tabpanelopt=columns:20
609 set equalalways
610 split
611 vsplit
612 END
613 call writefile(lines, 'XTest_tabpanel_equalalways', 'D')
614
615 let buf = RunVimInTerminal('-S XTest_tabpanel_equalalways', {'rows': 10, 'cols': 78})
616 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_0', {})
617 call term_sendkeys(buf, ":set tabpanelopt=columns:10\<CR>")
618 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_1', {})
619 call term_sendkeys(buf, ":set tabpanelopt=columns:30\<CR>")
620 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_2', {})
621 call term_sendkeys(buf, ":set tabpanelopt=columns:5\<CR>")
622 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_3', {})
623
624 call StopVimInTerminal(buf)
625endfunc
626
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200627function Test_tabpanel_quitall()
628 CheckScreendump
629
630 let lines =<< trim END
631 tabnew
632 set showtabpanel=1
633 set laststatus=2
634 call setline(1, 'aaa')
635 normal gt
636 silent! quitall
637 END
638 call writefile(lines, 'XTest_tabpanel_quitall', 'D')
639
640 let buf = RunVimInTerminal('-S XTest_tabpanel_quitall', {'rows': 10, 'cols': 45})
641 call VerifyScreenDump(buf, 'Test_tabpanel_quitall_0', {})
642
643 call StopVimInTerminal(buf)
644endfunc
645
646function Test_tabpanel_ruler()
647 CheckScreendump
648
649 let lines =<< trim END
650 tabnew
651 set statusline& laststatus=0
652 set rulerformat& ruler
653 set showtabpanel=1
654 END
655 call writefile(lines, 'XTest_tabpanel_ruler', 'D')
656
657 let buf = RunVimInTerminal('-S XTest_tabpanel_ruler', {'rows': 10, 'cols': 45})
658 call VerifyScreenDump(buf, 'Test_tabpanel_ruler_0', {})
659
660 call StopVimInTerminal(buf)
661endfunc
662
Christian Brabandta88c5bd2025-05-26 19:51:03 +0200663function Test_tabpanel_error()
664 set tabpanel=%!NonExistingFunc()
665 try
666 set showtabpanel=2
667 redraw!
668 catch /^Vim\%((\a\+)\)\=:E117:/
669 endtry
670 call assert_true(empty(&tabpanel))
Christian Brabandtac83b3c2025-05-27 20:49:34 +0200671
672 try
673 set tabpanel=%{my#util#TabPanelHighlight}%t
674 redraw!
675 catch /^Vim\%((\a\+)\)\=:E121:/
676 endtry
677 call assert_true(empty(&tabpanel))
678
Christian Brabandta88c5bd2025-05-26 19:51:03 +0200679 set tabpanel&vim
680 set showtabpanel&vim
681endfunc
Hirohito Higashi3ca67762025-06-10 20:19:04 +0200682
683function Test_tabpanel_with_msg_scrolled()
684 CheckScreendump
685
686 let lines =<< trim END
687 set showtabpanel=2
688 set noruler
689 tabnew
690 set modified
691 tabfirst
692 END
693 call writefile(lines, 'XTest_tabpanel_with_msg_scrolled', 'D')
694
695 let buf = RunVimInTerminal('-S XTest_tabpanel_with_msg_scrolled', {'rows': 10, 'cols': 45})
696 call VerifyScreenDump(buf, 'Test_tabpanel_with_msg_scrolled_0', {})
697 call term_sendkeys(buf, ":qa\<CR>")
698 call term_sendkeys(buf, "\<CR>")
699 call VerifyScreenDump(buf, 'Test_tabpanel_with_msg_scrolled_1', {})
700
701 call StopVimInTerminal(buf)
702endfunc
Hirohito Higashie5c96e32025-06-16 19:39:24 +0200703
704function Test_tabpanel_with_cmdline_pum()
705 CheckScreendump
706
707 let lines =<< trim END
708 set showtabpanel=2
709 set noruler
710 tabnew aaa
711 set wildoptions+=pum
712 func TimerCb(timer)
713 tabnew bbb
714 endfunc
715 call timer_start(100, 'TimerCb')
716 END
717 call writefile(lines, 'XTest_tabpanel_with_cmdline_pum', 'D')
718
719 let buf = RunVimInTerminal('-S XTest_tabpanel_with_cmdline_pum', {'rows': 10, 'cols': 45})
720 call term_sendkeys(buf, "\<C-L>")
721 call VerifyScreenDump(buf, 'Test_tabpanel_with_cmdline_pum_0', {})
722 call term_sendkeys(buf, ":set\<Tab>")
723 call term_wait(buf, 120)
724 call VerifyScreenDump(buf, 'Test_tabpanel_with_cmdline_pum_1', {})
725 call term_sendkeys(buf, "\<Esc>:tabclose\<CR>\<C-L>")
726 call VerifyScreenDump(buf, 'Test_tabpanel_with_cmdline_pum_0', {})
727
728 call StopVimInTerminal(buf)
729endfunc
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200730" vim: shiftwidth=2 sts=2 expandtab