annotate src/testdir/test_tabline.vim @ 31604:9b13b3a63bc0 v9.0.1134

patch 9.0.1134: comparing objects uses identity instead of equality Commit: https://github.com/vim/vim/commit/bcf31ec36b4b056bf06d21036640c6f0235e9c2b Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jan 2 20:32:24 2023 +0000 patch 9.0.1134: comparing objects uses identity instead of equality Problem: Comparing objects uses identity instead of equality. Solution: Compare the object values.
author Bram Moolenaar <Bram@vim.org>
date Mon, 02 Jan 2023 21:45:02 +0100
parents bb797331e21b
children 122cfa668b95
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21417
diff changeset
1 " Test for tabline
15396
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
2
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
3 source shared.vim
31457
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
4 source view_util.vim
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
5 source check.vim
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
6 source screendump.vim
15396
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
7
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
8 func TablineWithCaughtError()
8872
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 let s:func_in_tabline_called = 1
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 try
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 call eval('unknown expression')
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 catch
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 endtry
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 return ''
15396
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
15 endfunc
8872
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16
15396
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
17 func TablineWithError()
8872
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 let s:func_in_tabline_called = 1
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call eval('unknown expression')
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 return ''
15396
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
21 endfunc
8872
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22
15396
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
23 func Test_caught_error_in_tabline()
8874
ccab37bb9ac9 commit https://github.com/vim/vim/commit/73cd8fb3e87e4b29dfc489f58e56dee1839c18e5
Christian Brabandt <cb@256bit.org>
parents: 8872
diff changeset
24 if has('gui')
ccab37bb9ac9 commit https://github.com/vim/vim/commit/73cd8fb3e87e4b29dfc489f58e56dee1839c18e5
Christian Brabandt <cb@256bit.org>
parents: 8872
diff changeset
25 set guioptions-=e
ccab37bb9ac9 commit https://github.com/vim/vim/commit/73cd8fb3e87e4b29dfc489f58e56dee1839c18e5
Christian Brabandt <cb@256bit.org>
parents: 8872
diff changeset
26 endif
8872
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 let showtabline_save = &showtabline
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 set showtabline=2
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 let s:func_in_tabline_called = 0
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 let tabline = '%{TablineWithCaughtError()}'
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 let &tabline = tabline
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 redraw!
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 call assert_true(s:func_in_tabline_called)
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 call assert_equal(tabline, &tabline)
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 set tabline=
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 let &showtabline = showtabline_save
15396
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
37 endfunc
8872
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
15396
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
39 func Test_tabline_will_be_disabled_with_error()
8874
ccab37bb9ac9 commit https://github.com/vim/vim/commit/73cd8fb3e87e4b29dfc489f58e56dee1839c18e5
Christian Brabandt <cb@256bit.org>
parents: 8872
diff changeset
40 if has('gui')
ccab37bb9ac9 commit https://github.com/vim/vim/commit/73cd8fb3e87e4b29dfc489f58e56dee1839c18e5
Christian Brabandt <cb@256bit.org>
parents: 8872
diff changeset
41 set guioptions-=e
ccab37bb9ac9 commit https://github.com/vim/vim/commit/73cd8fb3e87e4b29dfc489f58e56dee1839c18e5
Christian Brabandt <cb@256bit.org>
parents: 8872
diff changeset
42 endif
8872
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 let showtabline_save = &showtabline
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 set showtabline=2
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 let s:func_in_tabline_called = 0
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 let tabline = '%{TablineWithError()}'
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 try
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 let &tabline = tabline
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 redraw!
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 catch
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 endtry
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call assert_true(s:func_in_tabline_called)
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 call assert_equal('', &tabline)
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 set tabline=
4d4de770f970 commit https://github.com/vim/vim/commit/f73d3bc253fa79ad220f52f04b93e782e95a9d43
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 let &showtabline = showtabline_save
15396
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
56 endfunc
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
57
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
58 func Test_redrawtabline()
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
59 if has('gui')
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
60 set guioptions-=e
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
61 endif
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
62 let showtabline_save = &showtabline
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
63 set showtabline=2
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
64 set tabline=%{bufnr('$')}
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
65 edit Xtabline1
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
66 edit Xtabline2
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
67 redraw
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
68 call assert_match(bufnr('$') . '', Screenline(1))
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
69 au BufAdd * redrawtabline
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
70 badd Xtabline3
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
71 call assert_match(bufnr('$') . '', Screenline(1))
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
72
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
73 set tabline=
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
74 let &showtabline = showtabline_save
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
75 au! Bufadd
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 8874
diff changeset
76 endfunc
21004
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
77
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
78 " Test for the "%T" and "%X" flags in the 'tabline' option
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
79 func MyTabLine()
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
80 let s = ''
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
81 for i in range(tabpagenr('$'))
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
82 " set the tab page number (for mouse clicks)
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
83 let s .= '%' . (i + 1) . 'T'
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
84
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
85 " the label is made by MyTabLabel()
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
86 let s .= ' %{MyTabLabel(' . (i + 1) . ')} '
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
87 endfor
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
88
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
89 " after the last tab fill with TabLineFill and reset tab page nr
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
90 let s .= '%T'
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
91
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
92 " right-align the label to close the current tab page
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
93 if tabpagenr('$') > 1
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
94 let s .= '%=%Xclose'
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
95 endif
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
96
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
97 return s
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
98 endfunc
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
99
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
100 func MyTabLabel(n)
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
101 let buflist = tabpagebuflist(a:n)
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
102 let winnr = tabpagewinnr(a:n)
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
103 return bufname(buflist[winnr - 1])
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
104 endfunc
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
105
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
106 func Test_tabline_flags()
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
107 if has('gui')
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
108 set guioptions-=e
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
109 endif
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
110 set tabline=%!MyTabLine()
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
111 edit Xtabline1
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
112 tabnew Xtabline2
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
113 redrawtabline
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
114 call assert_match('^ Xtabline1 Xtabline2\s\+close$', Screenline(1))
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
115 set tabline=
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
116 %bw!
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
117 endfunc
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
118
21417
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
119 function EmptyTabname()
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
120 return ""
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
121 endfunction
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
122
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
123 function MakeTabLine() abort
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
124 let titles = map(range(1, tabpagenr('$')), '"%( %" . v:val . "T%{EmptyTabname()}%T %)"')
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
125 let sep = 'あ'
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
126 let tabpages = join(titles, sep)
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
127 return tabpages .. sep .. '%=%999X X'
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
128 endfunction
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
129
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
130 func Test_tabline_empty_group()
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
131 " this was reading invalid memory
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
132 set tabline=%!MakeTabLine()
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
133 tabnew
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
134 redraw!
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
135
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
136 tabclose
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
137 set tabline=
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
138 endfunc
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
139
27786
fa675efa1e75 patch 8.2.4419: illegal memory access when using 20 highlights
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
140 " When there are exactly 20 tabline format items (the exact size of the
fa675efa1e75 patch 8.2.4419: illegal memory access when using 20 highlights
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
141 " initial tabline items array), test that we don't write beyond the size
fa675efa1e75 patch 8.2.4419: illegal memory access when using 20 highlights
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
142 " of the array.
fa675efa1e75 patch 8.2.4419: illegal memory access when using 20 highlights
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
143 func Test_tabline_20_format_items_no_overrun()
fa675efa1e75 patch 8.2.4419: illegal memory access when using 20 highlights
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
144 set showtabline=2
21417
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
145
27786
fa675efa1e75 patch 8.2.4419: illegal memory access when using 20 highlights
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
146 let tabline = repeat('%#StatColorHi2#', 20)
fa675efa1e75 patch 8.2.4419: illegal memory access when using 20 highlights
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
147 let &tabline = tabline
fa675efa1e75 patch 8.2.4419: illegal memory access when using 20 highlights
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
148 redrawtabline
fa675efa1e75 patch 8.2.4419: illegal memory access when using 20 highlights
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
149
fa675efa1e75 patch 8.2.4419: illegal memory access when using 20 highlights
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
150 set showtabline& tabline&
fa675efa1e75 patch 8.2.4419: illegal memory access when using 20 highlights
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
151 endfunc
21417
53ff4dfe6e11 patch 8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Bram Moolenaar <Bram@vim.org>
parents: 21004
diff changeset
152
29841
b37b74ea8dee patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents: 27786
diff changeset
153 func Test_mouse_click_in_tab()
b37b74ea8dee patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents: 27786
diff changeset
154 " This used to crash because TabPageIdxs[] was not initialized
b37b74ea8dee patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents: 27786
diff changeset
155 let lines =<< trim END
b37b74ea8dee patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents: 27786
diff changeset
156 tabnew
b37b74ea8dee patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents: 27786
diff changeset
157 set mouse=a
b37b74ea8dee patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents: 27786
diff changeset
158 exe "norm \<LeftMouse>"
b37b74ea8dee patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents: 27786
diff changeset
159 END
30865
c8ebe35b2475 patch 9.0.0767: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 29841
diff changeset
160 call writefile(lines, 'Xclickscript', 'D')
29841
b37b74ea8dee patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents: 27786
diff changeset
161 call RunVim([], [], "-e -s -S Xclickscript -c qa")
b37b74ea8dee patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents: 27786
diff changeset
162 endfunc
b37b74ea8dee patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents: 27786
diff changeset
163
31457
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
164 func Test_tabline_showcmd()
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
165 CheckScreendump
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
166
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
167 let lines =<< trim END
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
168 set showtabline=2
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
169 set showcmdloc=tabline
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
170 call setline(1, ['a', 'b', 'c'])
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
171 END
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
172 call writefile(lines, 'XTest_tabline', 'D')
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
173
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
174 let buf = RunVimInTerminal('-S XTest_tabline', {'rows': 6})
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
175
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
176 call feedkeys("\<C-V>Gl", "xt")
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
177 call VerifyScreenDump(buf, 'Test_tabline_showcmd_1', {})
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
178
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
179 call feedkeys("\<Esc>1234", "xt")
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
180 call VerifyScreenDump(buf, 'Test_tabline_showcmd_2', {})
bb797331e21b patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents: 30865
diff changeset
181 endfunc
29841
b37b74ea8dee patch 9.0.0259: crash with mouse click when not initialized
Bram Moolenaar <Bram@vim.org>
parents: 27786
diff changeset
182
21004
0650d220f742 patch 8.2.1053: insufficient testing for 'statusline' and 'tabline'
Bram Moolenaar <Bram@vim.org>
parents: 15396
diff changeset
183 " vim: shiftwidth=2 sts=2 expandtab