xref: /vim-8.2.3635/src/testdir/test_conceal.vim (revision 577fadfc)
1" Tests for 'conceal'.
2" Also see test88.in (should be converted to a test function here).
3
4if !has('conceal')
5  finish
6endif
7
8source screendump.vim
9if !CanRunVimInTerminal()
10  finish
11endif
12
13func Test_conceal_two_windows()
14  call writefile([
15	\ 'let lines = ["one one one one one", "two |hidden| here", "three |hidden| three"]',
16	\ 'call setline(1, lines)',
17	\ 'syntax match test /|hidden|/ conceal',
18	\ 'set conceallevel=2',
19	\ 'set concealcursor=',
20	\ 'exe "normal /here\r"',
21	\ 'new',
22	\ 'call setline(1, lines)',
23	\ 'call setline(4, "Second window")',
24	\ 'syntax match test /|hidden|/ conceal',
25	\ 'set conceallevel=2',
26	\ 'set concealcursor=nc',
27	\ 'exe "normal /here\r"',
28	\ ], 'XTest_conceal')
29  " Check that cursor line is concealed
30  let buf = RunVimInTerminal('-S XTest_conceal', {})
31  call VerifyScreenDump(buf, 'Test_conceal_two_windows_01', {})
32
33  " Check that with concealed text vertical cursor movement is correct.
34  call term_sendkeys(buf, "k")
35  call VerifyScreenDump(buf, 'Test_conceal_two_windows_02', {})
36
37  " Check that with cursor line is not concealed
38  call term_sendkeys(buf, "j")
39  call term_sendkeys(buf, ":set concealcursor=\r")
40  call VerifyScreenDump(buf, 'Test_conceal_two_windows_03', {})
41
42  " Check that with cursor line is not concealed when moving cursor down
43  call term_sendkeys(buf, "j")
44  call VerifyScreenDump(buf, 'Test_conceal_two_windows_04', {})
45
46  " Check that with cursor line is not concealed when switching windows
47  call term_sendkeys(buf, "\<C-W>\<C-W>")
48  call VerifyScreenDump(buf, 'Test_conceal_two_windows_05', {})
49
50  " Check that with cursor line is only concealed in Normal mode
51  call term_sendkeys(buf, ":set concealcursor=n\r")
52  call VerifyScreenDump(buf, 'Test_conceal_two_windows_06n', {})
53  call term_sendkeys(buf, "a")
54  call VerifyScreenDump(buf, 'Test_conceal_two_windows_06i', {})
55  call term_sendkeys(buf, "\<Esc>/e")
56  call VerifyScreenDump(buf, 'Test_conceal_two_windows_06c', {})
57  call term_sendkeys(buf, "\<Esc>v")
58  call VerifyScreenDump(buf, 'Test_conceal_two_windows_06v', {})
59  call term_sendkeys(buf, "\<Esc>")
60
61  " Check that with cursor line is only concealed in Insert mode
62  call term_sendkeys(buf, ":set concealcursor=i\r")
63  call VerifyScreenDump(buf, 'Test_conceal_two_windows_07n', {})
64  call term_sendkeys(buf, "a")
65  call VerifyScreenDump(buf, 'Test_conceal_two_windows_07i', {})
66  call term_sendkeys(buf, "\<Esc>/e")
67  call VerifyScreenDump(buf, 'Test_conceal_two_windows_07c', {})
68  call term_sendkeys(buf, "\<Esc>v")
69  call VerifyScreenDump(buf, 'Test_conceal_two_windows_07v', {})
70  call term_sendkeys(buf, "\<Esc>")
71
72  " Check that with cursor line is only concealed in Command mode
73  call term_sendkeys(buf, ":set concealcursor=c\r")
74  call VerifyScreenDump(buf, 'Test_conceal_two_windows_08n', {})
75  call term_sendkeys(buf, "a")
76  call VerifyScreenDump(buf, 'Test_conceal_two_windows_08i', {})
77  call term_sendkeys(buf, "\<Esc>/e")
78  call VerifyScreenDump(buf, 'Test_conceal_two_windows_08c', {})
79  call term_sendkeys(buf, "\<Esc>v")
80  call VerifyScreenDump(buf, 'Test_conceal_two_windows_08v', {})
81  call term_sendkeys(buf, "\<Esc>")
82
83  " Check that with cursor line is only concealed in Visual mode
84  call term_sendkeys(buf, ":set concealcursor=v\r")
85  call VerifyScreenDump(buf, 'Test_conceal_two_windows_09n', {})
86  call term_sendkeys(buf, "a")
87  call VerifyScreenDump(buf, 'Test_conceal_two_windows_09i', {})
88  call term_sendkeys(buf, "\<Esc>/e")
89  call VerifyScreenDump(buf, 'Test_conceal_two_windows_09c', {})
90  call term_sendkeys(buf, "\<Esc>v")
91  call VerifyScreenDump(buf, 'Test_conceal_two_windows_09v', {})
92  call term_sendkeys(buf, "\<Esc>")
93
94  " Check moving the cursor while in insert mode.
95  call term_sendkeys(buf, ":set concealcursor=\r")
96  call term_sendkeys(buf, "a")
97  call VerifyScreenDump(buf, 'Test_conceal_two_windows_10', {})
98  call term_sendkeys(buf, "\<Down>")
99  call VerifyScreenDump(buf, 'Test_conceal_two_windows_11', {})
100  call term_sendkeys(buf, "\<Esc>")
101
102  " Check the "o" command
103  call VerifyScreenDump(buf, 'Test_conceal_two_windows_12', {})
104  call term_sendkeys(buf, "o")
105  call VerifyScreenDump(buf, 'Test_conceal_two_windows_13', {})
106  call term_sendkeys(buf, "\<Esc>")
107
108  " clean up
109  call StopVimInTerminal(buf)
110  call delete('XTest_conceal')
111endfunc
112
113func Test_conceal_with_cursorline()
114  " Opens a help window, where 'conceal' is set, switches to the other window
115  " where 'cursorline' needs to be updated when the cursor moves.
116  call writefile([
117	\ 'set cursorline',
118	\ 'normal othis is a test',
119	\ 'new',
120	\ 'call setline(1, ["one", "two", "three", "four", "five"])',
121	\ 'set ft=help',
122	\ 'normal M',
123	\ ], 'XTest_conceal_cul')
124  let buf = RunVimInTerminal('-S XTest_conceal_cul', {})
125  call VerifyScreenDump(buf, 'Test_conceal_cul_01', {})
126
127  call term_sendkeys(buf, ":wincmd w\r")
128  call VerifyScreenDump(buf, 'Test_conceal_cul_02', {})
129
130  call term_sendkeys(buf, "k")
131  call VerifyScreenDump(buf, 'Test_conceal_cul_03', {})
132
133  " clean up
134  call StopVimInTerminal(buf)
135  call delete('XTest_conceal_cul')
136endfunc
137