1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute
local insert = helpers.insert
if helpers.pending_win32(pending) then return end
describe('Screen', function()
local screen
before_each(function()
clear()
screen = Screen.new(nil,10)
screen:attach()
screen:set_default_attr_ids( {
[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray}
} )
end)
after_each(function()
screen:detach()
end)
describe("match and conceal", function()
before_each(function()
execute("let &conceallevel=1")
end)
describe("multiple", function()
before_each(function()
insert([[
&&
&&
&&
&&
&&
&&
]])
execute("syn match dAmpersand '[&][&]' conceal cchar=∧")
end)
it("double characters.", function()
screen:expect([[
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
^ |
{0:~ }|
{0:~ }|
:syn match dAmpersand '[&][&]' conceal cchar=∧ |
]])
end)
it('double characters and move the cursor one line up.', function()
feed("k")
screen:expect([[
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
^&& |
|
{0:~ }|
{0:~ }|
:syn match dAmpersand '[&][&]' conceal cchar=∧ |
]])
end)
it('double characters and move the cursor to the beginning of the file.', function()
feed("gg")
screen:expect([[
^&& |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
|
{0:~ }|
{0:~ }|
:syn match dAmpersand '[&][&]' conceal cchar=∧ |
]])
end)
it('double characters and move the cursor to the second line in the file.', function()
feed("ggj")
screen:expect([[
{1:∧} |
^&& |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
|
{0:~ }|
{0:~ }|
:syn match dAmpersand '[&][&]' conceal cchar=∧ |
]])
end)
it('double characters and then move the cursor to the beginning of the file and back to the end of the file.', function()
feed("ggG")
screen:expect([[
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
^ |
{0:~ }|
{0:~ }|
:syn match dAmpersand '[&][&]' conceal cchar=∧ |
]])
end)
end) -- multiple
it("keyword instances in initially in the document.", function()
feed("2ilambda<cr><ESC>")
execute("let &conceallevel=1")
execute("syn keyword kLambda lambda conceal cchar=λ")
screen:expect([[
{1:λ} |
{1:λ} |
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
:syn keyword kLambda lambda conceal cchar=λ |
]])
end) -- Keyword
describe("regions in the document", function()
before_each(function()
feed("2")
insert("<r> a region of text </r>\n")
execute("let &conceallevel=1")
end)
it('initially and conceal it.', function()
execute("syn region rText start='<r>' end='</r>' conceal cchar=R")
screen:expect([[
{1:R} |
{1:R} |
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
end)
it('initially and conceal its start tag and end tag.', function()
-- concealends has a known bug (todo.txt) where the first match won't
-- be replaced with cchar.
execute("syn region rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-")
screen:expect([[
{1: } a region of text {1:-} |
{1: } a region of text {1:-} |
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
end)
it('that are nested and conceal the nested region\'s start and end tags.', function()
execute("syn region rText contains=rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-")
insert("<r> A region with <r> a nested <r> nested region.</r> </r> </r>\n")
screen:expect([[
{1: } a region of text {1:-} |
{1: } a region of text {1:-} |
{1: } A region with {1: } a nested {1: } nested region.{1:-} |
{1:-} {1:-} |
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
end)
end) -- regions in the document
describe("a region of text", function()
before_each(function()
execute("syntax conceal on")
feed("2")
insert("<r> a region of text </r>\n")
execute("syn region rText start='<r>' end='</r>' cchar=-")
end)
it("and turn on implicit concealing", function()
screen:expect([[
{1:-} |
{1:-} |
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
:syn region rText start='<r>' end='</r>' cchar=- |
]])
end)
it("and then turn on, then off, and then back on implicit concealing.", function()
execute("syntax conceal off")
feed("2")
insert("<i> italian text </i>\n")
execute("syn region iText start='<i>' end='</i>' cchar=*")
screen:expect([[
{1:-} |
{1:-} |
<i> italian text </i> |
<i> italian text </i> |
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
:syn region iText start='<i>' end='</i>' cchar=* |
]])
execute("syntax conceal on")
execute("syn region iText start='<i>' end='</i>' cchar=*")
screen:expect([[
{1:-} |
{1:-} |
{1:*} |
{1:*} |
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
:syn region iText start='<i>' end='</i>' cchar=* |
]])
end)
end) -- a region of text (implicit concealing)
end) -- match and conceal
describe("let the conceal level be", function()
before_each(function()
insert("// No Conceal\n")
insert('"Conceal without a cchar"\n')
insert("+ With cchar\n\n")
execute("syn match noConceal '^//.*$'")
execute("syn match concealNoCchar '\".\\{-}\"$' conceal")
execute("syn match concealWCchar '^+.\\{-}$' conceal cchar=C")
end)
it("0. No concealing.", function()
execute("let &conceallevel=0")
screen:expect([[
// No Conceal |
"Conceal without a cchar" |
+ With cchar |
|
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
:let &conceallevel=0 |
]])
end)
it("1. Conceal using cchar or reference listchars.", function()
execute("let &conceallevel=1")
screen:expect([[
// No Conceal |
{1: } |
{1:C} |
|
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
:let &conceallevel=1 |
]])
end)
it("2. Hidden unless cchar is set.", function()
execute("let &conceallevel=2")
screen:expect([[
// No Conceal |
|
{1:C} |
|
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
:let &conceallevel=2 |
]])
end)
it("3. Hide all concealed text.", function()
execute("let &conceallevel=3")
screen:expect([[
// No Conceal |
|
|
|
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
:let &conceallevel=3 |
]])
end)
end) -- conceallevel
end)
|