blob: f114651c2111e0a15f042f908e53677df4af760e [file] [log] [blame]
Bram Moolenaar429ab172019-01-11 15:54:45 +01001" Tests for 'conceal'.
2" Also see test88.in (should be converted to a test function here).
3
4if !has('conceal')
Bram Moolenaar5d30ff12019-06-06 16:12:12 +02005 throw 'Skipped: conceal feature missing'
Bram Moolenaar429ab172019-01-11 15:54:45 +01006endif
7
8source screendump.vim
9if !CanRunVimInTerminal()
Bram Moolenaar5d30ff12019-06-06 16:12:12 +020010 throw 'Skipped: cannot make screendumps'
Bram Moolenaar429ab172019-01-11 15:54:45 +010011endif
12
13func Test_conceal_two_windows()
Bram Moolenaarc79745a2019-05-20 22:12:34 +020014 let code =<< trim [CODE]
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 [CODE]
29
30 call writefile(code, 'XTest_conceal')
Bram Moolenaar429ab172019-01-11 15:54:45 +010031 " Check that cursor line is concealed
32 let buf = RunVimInTerminal('-S XTest_conceal', {})
33 call VerifyScreenDump(buf, 'Test_conceal_two_windows_01', {})
34
35 " Check that with concealed text vertical cursor movement is correct.
36 call term_sendkeys(buf, "k")
37 call VerifyScreenDump(buf, 'Test_conceal_two_windows_02', {})
38
39 " Check that with cursor line is not concealed
40 call term_sendkeys(buf, "j")
41 call term_sendkeys(buf, ":set concealcursor=\r")
42 call VerifyScreenDump(buf, 'Test_conceal_two_windows_03', {})
43
44 " Check that with cursor line is not concealed when moving cursor down
45 call term_sendkeys(buf, "j")
46 call VerifyScreenDump(buf, 'Test_conceal_two_windows_04', {})
47
48 " Check that with cursor line is not concealed when switching windows
49 call term_sendkeys(buf, "\<C-W>\<C-W>")
50 call VerifyScreenDump(buf, 'Test_conceal_two_windows_05', {})
51
52 " Check that with cursor line is only concealed in Normal mode
53 call term_sendkeys(buf, ":set concealcursor=n\r")
54 call VerifyScreenDump(buf, 'Test_conceal_two_windows_06n', {})
55 call term_sendkeys(buf, "a")
56 call VerifyScreenDump(buf, 'Test_conceal_two_windows_06i', {})
57 call term_sendkeys(buf, "\<Esc>/e")
58 call VerifyScreenDump(buf, 'Test_conceal_two_windows_06c', {})
59 call term_sendkeys(buf, "\<Esc>v")
60 call VerifyScreenDump(buf, 'Test_conceal_two_windows_06v', {})
61 call term_sendkeys(buf, "\<Esc>")
62
63 " Check that with cursor line is only concealed in Insert mode
64 call term_sendkeys(buf, ":set concealcursor=i\r")
65 call VerifyScreenDump(buf, 'Test_conceal_two_windows_07n', {})
66 call term_sendkeys(buf, "a")
67 call VerifyScreenDump(buf, 'Test_conceal_two_windows_07i', {})
68 call term_sendkeys(buf, "\<Esc>/e")
69 call VerifyScreenDump(buf, 'Test_conceal_two_windows_07c', {})
70 call term_sendkeys(buf, "\<Esc>v")
71 call VerifyScreenDump(buf, 'Test_conceal_two_windows_07v', {})
72 call term_sendkeys(buf, "\<Esc>")
73
74 " Check that with cursor line is only concealed in Command mode
75 call term_sendkeys(buf, ":set concealcursor=c\r")
76 call VerifyScreenDump(buf, 'Test_conceal_two_windows_08n', {})
77 call term_sendkeys(buf, "a")
78 call VerifyScreenDump(buf, 'Test_conceal_two_windows_08i', {})
79 call term_sendkeys(buf, "\<Esc>/e")
80 call VerifyScreenDump(buf, 'Test_conceal_two_windows_08c', {})
81 call term_sendkeys(buf, "\<Esc>v")
82 call VerifyScreenDump(buf, 'Test_conceal_two_windows_08v', {})
83 call term_sendkeys(buf, "\<Esc>")
84
85 " Check that with cursor line is only concealed in Visual mode
86 call term_sendkeys(buf, ":set concealcursor=v\r")
87 call VerifyScreenDump(buf, 'Test_conceal_two_windows_09n', {})
88 call term_sendkeys(buf, "a")
89 call VerifyScreenDump(buf, 'Test_conceal_two_windows_09i', {})
90 call term_sendkeys(buf, "\<Esc>/e")
91 call VerifyScreenDump(buf, 'Test_conceal_two_windows_09c', {})
92 call term_sendkeys(buf, "\<Esc>v")
93 call VerifyScreenDump(buf, 'Test_conceal_two_windows_09v', {})
94 call term_sendkeys(buf, "\<Esc>")
95
Bram Moolenaar465e8b52019-01-11 20:42:28 +010096 " Check moving the cursor while in insert mode.
97 call term_sendkeys(buf, ":set concealcursor=\r")
98 call term_sendkeys(buf, "a")
99 call VerifyScreenDump(buf, 'Test_conceal_two_windows_10', {})
100 call term_sendkeys(buf, "\<Down>")
101 call VerifyScreenDump(buf, 'Test_conceal_two_windows_11', {})
102 call term_sendkeys(buf, "\<Esc>")
103
104 " Check the "o" command
105 call VerifyScreenDump(buf, 'Test_conceal_two_windows_12', {})
106 call term_sendkeys(buf, "o")
107 call VerifyScreenDump(buf, 'Test_conceal_two_windows_13', {})
108 call term_sendkeys(buf, "\<Esc>")
109
Bram Moolenaar429ab172019-01-11 15:54:45 +0100110 " clean up
111 call StopVimInTerminal(buf)
112 call delete('XTest_conceal')
113endfunc
Bram Moolenaarbbee8d52019-01-14 21:51:40 +0100114
115func Test_conceal_with_cursorline()
116 " Opens a help window, where 'conceal' is set, switches to the other window
117 " where 'cursorline' needs to be updated when the cursor moves.
Bram Moolenaarc79745a2019-05-20 22:12:34 +0200118 let code =<< trim [CODE]
119 set cursorline
120 normal othis is a test
121 new
122 call setline(1, ["one", "two", "three", "four", "five"])
123 set ft=help
124 normal M
125 [CODE]
126
127 call writefile(code, 'XTest_conceal_cul')
Bram Moolenaarbbee8d52019-01-14 21:51:40 +0100128 let buf = RunVimInTerminal('-S XTest_conceal_cul', {})
129 call VerifyScreenDump(buf, 'Test_conceal_cul_01', {})
130
131 call term_sendkeys(buf, ":wincmd w\r")
132 call VerifyScreenDump(buf, 'Test_conceal_cul_02', {})
133
134 call term_sendkeys(buf, "k")
135 call VerifyScreenDump(buf, 'Test_conceal_cul_03', {})
136
137 " clean up
138 call StopVimInTerminal(buf)
139 call delete('XTest_conceal_cul')
140endfunc