blob: 1dd5aa6b036eb53b9c738f6876bccf494b182ee6 [file] [log] [blame]
Bram Moolenaar6c896862016-11-17 19:46:51 +01001" Test for breakindent
2"
3" Note: if you get strange failures when adding new tests, it might be that
4" while the test is run, the breakindent cacheing gets in its way.
Bram Moolenaar544d3bc2017-02-05 21:14:50 +01005" It helps to change the tabstop setting and force a redraw (e.g. see
Bram Moolenaar6c896862016-11-17 19:46:51 +01006" Test_breakindent08())
7if !exists('+breakindent')
Bram Moolenaar5d30ff12019-06-06 16:12:12 +02008 throw 'Skipped: breakindent option not supported'
Bram Moolenaar6c896862016-11-17 19:46:51 +01009endif
10
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010011source view_util.vim
12
Bram Moolenaar6c896862016-11-17 19:46:51 +010013let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP"
14
Bram Moolenaar04958cb2018-06-23 19:23:02 +020015func s:screen_lines(lnum, width) abort
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010016 return ScreenLines([a:lnum, a:lnum + 2], a:width)
Bram Moolenaar04958cb2018-06-23 19:23:02 +020017endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +010018
Bram Moolenaar04958cb2018-06-23 19:23:02 +020019func s:compare_lines(expect, actual)
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010020 call assert_equal(join(a:expect, "\n"), join(a:actual, "\n"))
Bram Moolenaar04958cb2018-06-23 19:23:02 +020021endfunc
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010022
Bram Moolenaar04958cb2018-06-23 19:23:02 +020023func s:test_windows(...)
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010024 call NewWindow(10, 20)
25 setl ts=4 sw=4 sts=4 breakindent
Bram Moolenaar6c896862016-11-17 19:46:51 +010026 put =s:input
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010027 exe get(a:000, 0, '')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020028endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +010029
Bram Moolenaar04958cb2018-06-23 19:23:02 +020030func s:close_windows(...)
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010031 call CloseWindow()
32 exe get(a:000, 0, '')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020033endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +010034
Bram Moolenaar04958cb2018-06-23 19:23:02 +020035func Test_breakindent01()
Bram Moolenaar6c896862016-11-17 19:46:51 +010036 " simple breakindent test
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010037 call s:test_windows('setl briopt=min:0')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020038 let lines = s:screen_lines(line('.'),8)
39 let expect = [
40 \ " abcd",
41 \ " qrst",
42 \ " GHIJ",
43 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010044 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +010045 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +020046endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +010047
Bram Moolenaar04958cb2018-06-23 19:23:02 +020048func Test_breakindent01_vartabs()
49 " like 01 but with vartabs feature
50 if !has("vartabs")
51 return
52 endif
53 call s:test_windows('setl briopt=min:0 vts=4')
54 let lines = s:screen_lines(line('.'),8)
55 let expect = [
56 \ " abcd",
57 \ " qrst",
58 \ " GHIJ",
59 \ ]
60 call s:compare_lines(expect, lines)
61 call s:close_windows('set vts&')
62endfunc
63
64func Test_breakindent02()
Bram Moolenaar6c896862016-11-17 19:46:51 +010065 " simple breakindent test with showbreak set
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010066 call s:test_windows('setl briopt=min:0 sbr=>>')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020067 let lines = s:screen_lines(line('.'),8)
68 let expect = [
69 \ " abcd",
70 \ " >>qr",
71 \ " >>EF",
72 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010073 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +010074 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020075endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +010076
Bram Moolenaar04958cb2018-06-23 19:23:02 +020077func Test_breakindent02_vartabs()
78 if !has("vartabs")
79 return
80 endif
81 " simple breakindent test with showbreak set
82 call s:test_windows('setl briopt=min:0 sbr=>> vts=4')
83 let lines = s:screen_lines(line('.'),8)
84 let expect = [
85 \ " abcd",
86 \ " >>qr",
87 \ " >>EF",
88 \ ]
89 call s:compare_lines(expect, lines)
90 call s:close_windows('set sbr= vts&')
91endfunc
92
93func Test_breakindent03()
Bram Moolenaar6c896862016-11-17 19:46:51 +010094 " simple breakindent test with showbreak set and briopt including sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010095 call s:test_windows('setl briopt=sbr,min:0 sbr=++')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020096 let lines = s:screen_lines(line('.'),8)
97 let expect = [
98 \ " abcd",
99 \ "++ qrst",
100 \ "++ GHIJ",
101 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100102 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100103 " clean up
104 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200105endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100106
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200107func Test_breakindent03_vartabs()
108 " simple breakindent test with showbreak set and briopt including sbr
109 if !has("vartabs")
110 return
111 endif
112 call s:test_windows('setl briopt=sbr,min:0 sbr=++ vts=4')
113 let lines = s:screen_lines(line('.'),8)
114 let expect = [
115 \ " abcd",
116 \ "++ qrst",
117 \ "++ GHIJ",
118 \ ]
119 call s:compare_lines(expect, lines)
120 " clean up
121 call s:close_windows('set sbr= vts&')
122endfunc
123
124func Test_breakindent04()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100125 " breakindent set with min width 18
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100126 call s:test_windows('setl sbr= briopt=min:18')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200127 let lines = s:screen_lines(line('.'),8)
128 let expect = [
129 \ " abcd",
130 \ " qrstuv",
131 \ " IJKLMN",
132 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100133 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100134 " clean up
135 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200136endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100137
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200138func Test_breakindent04_vartabs()
139 " breakindent set with min width 18
140 if !has("vartabs")
141 return
142 endif
143 call s:test_windows('setl sbr= briopt=min:18 vts=4')
144 let lines = s:screen_lines(line('.'),8)
145 let expect = [
146 \ " abcd",
147 \ " qrstuv",
148 \ " IJKLMN",
149 \ ]
150 call s:compare_lines(expect, lines)
151 " clean up
152 call s:close_windows('set sbr= vts&')
153endfunc
154
155func Test_breakindent05()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100156 " breakindent set and shift by 2
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100157 call s:test_windows('setl briopt=shift:2,min:0')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200158 let lines = s:screen_lines(line('.'),8)
159 let expect = [
160 \ " abcd",
161 \ " qr",
162 \ " EF",
163 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100164 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100165 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200166endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100167
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200168func Test_breakindent05_vartabs()
169 " breakindent set and shift by 2
170 if !has("vartabs")
171 return
172 endif
173 call s:test_windows('setl briopt=shift:2,min:0 vts=4')
174 let lines = s:screen_lines(line('.'),8)
175 let expect = [
176 \ " abcd",
177 \ " qr",
178 \ " EF",
179 \ ]
180 call s:compare_lines(expect, lines)
181 call s:close_windows('set vts&')
182endfunc
183
184func Test_breakindent06()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100185 " breakindent set and shift by -1
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100186 call s:test_windows('setl briopt=shift:-1,min:0')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200187 let lines = s:screen_lines(line('.'),8)
188 let expect = [
189 \ " abcd",
190 \ " qrstu",
191 \ " HIJKL",
192 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100193 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100194 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200195endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100196
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200197func Test_breakindent06_vartabs()
198 " breakindent set and shift by -1
199 if !has("vartabs")
200 return
201 endif
202 call s:test_windows('setl briopt=shift:-1,min:0 vts=4')
203 let lines = s:screen_lines(line('.'),8)
204 let expect = [
205 \ " abcd",
206 \ " qrstu",
207 \ " HIJKL",
208 \ ]
209 call s:compare_lines(expect, lines)
210 call s:close_windows('set vts&')
211endfunc
212
213func Test_breakindent07()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100214 " breakindent set and shift by 1, Number set sbr=? and briopt:sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100215 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200216 let lines = s:screen_lines(line('.'),10)
217 let expect = [
218 \ " 2 ab",
219 \ "? m",
220 \ "? x",
221 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100222 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100223 " clean up
224 call s:close_windows('set sbr= cpo-=n')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200225endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100226
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200227func Test_breakindent07_vartabs()
228 if !has("vartabs")
229 return
230 endif
231 " breakindent set and shift by 1, Number set sbr=? and briopt:sbr
232 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n vts=4')
233 let lines = s:screen_lines(line('.'),10)
234 let expect = [
235 \ " 2 ab",
236 \ "? m",
237 \ "? x",
238 \ ]
239 call s:compare_lines(expect, lines)
240 " clean up
241 call s:close_windows('set sbr= cpo-=n vts&')
242endfunc
243
244func Test_breakindent07a()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100245 " breakindent set and shift by 1, Number set sbr=? and briopt:sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100246 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200247 let lines = s:screen_lines(line('.'),10)
248 let expect = [
249 \ " 2 ab",
250 \ " ? m",
251 \ " ? x",
252 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100253 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100254 " clean up
255 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200256endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100257
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200258func Test_breakindent07a_vartabs()
259 if !has("vartabs")
260 return
261 endif
262 " breakindent set and shift by 1, Number set sbr=? and briopt:sbr
263 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 vts=4')
264 let lines = s:screen_lines(line('.'),10)
265 let expect = [
266 \ " 2 ab",
267 \ " ? m",
268 \ " ? x",
269 \ ]
270 call s:compare_lines(expect, lines)
271 " clean up
272 call s:close_windows('set sbr= vts&')
273endfunc
274
275func Test_breakindent08()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100276 " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100277 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100278 " make sure, cache is invalidated!
279 set ts=8
280 redraw!
281 set ts=4
282 redraw!
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200283 let lines = s:screen_lines(line('.'),10)
284 let expect = [
285 \ " 2 ^Iabcd",
286 \ "# opq",
287 \ "# BCD",
288 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100289 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100290 call s:close_windows('set sbr= cpo-=n')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200291endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100292
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200293func Test_breakindent08_vartabs()
294 if !has("vartabs")
295 return
296 endif
297 " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
298 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4 vts=4')
299 " make sure, cache is invalidated!
300 set ts=8
301 redraw!
302 set ts=4
303 redraw!
304 let lines = s:screen_lines(line('.'),10)
305 let expect = [
306 \ " 2 ^Iabcd",
307 \ "# opq",
308 \ "# BCD",
309 \ ]
310 call s:compare_lines(expect, lines)
311 call s:close_windows('set sbr= cpo-=n vts&')
312endfunc
313
314func Test_breakindent08a()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100315 " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100316 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200317 let lines = s:screen_lines(line('.'),10)
318 let expect = [
319 \ " 2 ^Iabcd",
320 \ " # opq",
321 \ " # BCD",
322 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100323 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100324 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200325endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100326
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200327func Test_breakindent08a_vartabs()
328 if !has("vartabs")
329 return
330 endif
331 " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
332 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list vts=4')
333 let lines = s:screen_lines(line('.'),10)
334 let expect = [
335 \ " 2 ^Iabcd",
336 \ " # opq",
337 \ " # BCD",
338 \ ]
339 call s:compare_lines(expect, lines)
340 call s:close_windows('set sbr= vts&')
341endfunc
342
343func Test_breakindent09()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100344 " breakindent set and shift by 1, Number and list set sbr=#
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100345 call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200346 let lines = s:screen_lines(line('.'),10)
347 let expect = [
348 \ " 2 ^Iabcd",
349 \ " #op",
350 \ " #AB",
351 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100352 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100353 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200354endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100355
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200356func Test_breakindent09_vartabs()
357 if !has("vartabs")
358 return
359 endif
360 " breakindent set and shift by 1, Number and list set sbr=#
361 call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list vts=4')
362 let lines = s:screen_lines(line('.'),10)
363 let expect = [
364 \ " 2 ^Iabcd",
365 \ " #op",
366 \ " #AB",
367 \ ]
368 call s:compare_lines(expect, lines)
369 call s:close_windows('set sbr= vts&')
370endfunc
371
372func Test_breakindent10()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100373 " breakindent set, Number set sbr=~
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100374 call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100375 " make sure, cache is invalidated!
376 set ts=8
377 redraw!
378 set ts=4
379 redraw!
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200380 let lines = s:screen_lines(line('.'),10)
381 let expect = [
382 \ " 2 ab",
383 \ "~ mn",
384 \ "~ yz",
385 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100386 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100387 call s:close_windows('set sbr= cpo-=n')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200388endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100389
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200390func Test_breakindent10_vartabs()
391 if !has("vartabs")
392 return
393 endif
394 " breakindent set, Number set sbr=~
395 call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0 vts=4')
396 " make sure, cache is invalidated!
397 set ts=8
398 redraw!
399 set ts=4
400 redraw!
401 let lines = s:screen_lines(line('.'),10)
402 let expect = [
403 \ " 2 ab",
404 \ "~ mn",
405 \ "~ yz",
406 \ ]
407 call s:compare_lines(expect, lines)
408 call s:close_windows('set sbr= cpo-=n vts&')
409endfunc
410
411func Test_breakindent11()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100412 " test strdisplaywidth()
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100413 call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200414 let text = getline(2)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100415 let width = strlen(text[1:])+indent(2)+strlen(&sbr)*3 " text wraps 3 times
416 call assert_equal(width, strdisplaywidth(text))
417 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200418endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100419
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200420func Test_breakindent11_vartabs()
421 if !has("vartabs")
422 return
423 endif
424 " test strdisplaywidth()
425 call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4')
426 let text = getline(2)
427 let width = strlen(text[1:])+indent(2)+strlen(&sbr)*3 " text wraps 3 times
428 call assert_equal(width, strdisplaywidth(text))
429 call s:close_windows('set sbr= vts&')
430endfunc
431
432func Test_breakindent12()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100433 " test breakindent with long indent
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200434 let s:input = "\t\t\t\t\t{"
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100435 call s:test_windows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>-')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200436 let lines = s:screen_lines(2,16)
437 let expect = [
438 \ " 2 >--->--->--->",
439 \ " ---{ ",
440 \ "~ ",
441 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100442 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100443 call s:close_windows('set nuw=4 listchars=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200444endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100445
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200446func Test_breakindent12_vartabs()
447 if !has("vartabs")
448 return
449 endif
450 " test breakindent with long indent
451 let s:input = "\t\t\t\t\t{"
452 call s:test_windows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>- vts=4')
453 let lines = s:screen_lines(2,16)
454 let expect = [
455 \ " 2 >--->--->--->",
456 \ " ---{ ",
457 \ "~ ",
458 \ ]
459 call s:compare_lines(expect, lines)
460 call s:close_windows('set nuw=4 listchars= vts&')
461endfunc
462
463func Test_breakindent13()
464 let s:input = ""
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100465 call s:test_windows('setl breakindent briopt=min:10 ts=8')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100466 vert resize 20
467 call setline(1, [" a\tb\tc\td\te", " z y x w v"])
468 1
469 norm! fbgj"ayl
470 2
471 norm! fygj"byl
472 call assert_equal('d', @a)
473 call assert_equal('w', @b)
474 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200475endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100476
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200477func Test_breakindent13_vartabs()
478 if !has("vartabs")
479 return
480 endif
481 let s:input = ""
482 call s:test_windows('setl breakindent briopt=min:10 ts=8 vts=8')
483 vert resize 20
484 call setline(1, [" a\tb\tc\td\te", " z y x w v"])
485 1
486 norm! fbgj"ayl
487 2
488 norm! fygj"byl
489 call assert_equal('d', @a)
490 call assert_equal('w', @b)
491 call s:close_windows('set vts&')
492endfunc
493
494func Test_breakindent14()
495 let s:input = ""
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100496 call s:test_windows('setl breakindent briopt= ts=8')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100497 vert resize 30
498 norm! 3a1234567890
499 norm! a abcde
500 exec "norm! 0\<C-V>tex"
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200501 let lines = s:screen_lines(line('.'),8)
502 let expect = [
503 \ "e ",
504 \ "~ ",
505 \ "~ ",
506 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100507 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100508 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200509endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100510
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200511func Test_breakindent14_vartabs()
512 if !has("vartabs")
513 return
514 endif
515 let s:input = ""
516 call s:test_windows('setl breakindent briopt= ts=8 vts=8')
517 vert resize 30
518 norm! 3a1234567890
519 norm! a abcde
520 exec "norm! 0\<C-V>tex"
521 let lines = s:screen_lines(line('.'),8)
522 let expect = [
523 \ "e ",
524 \ "~ ",
525 \ "~ ",
526 \ ]
527 call s:compare_lines(expect, lines)
528 call s:close_windows('set vts&')
529endfunc
530
531func Test_breakindent15()
532 let s:input = ""
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100533 call s:test_windows('setl breakindent briopt= ts=8 sw=8')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100534 vert resize 30
535 norm! 4a1234567890
536 exe "normal! >>\<C-V>3f0x"
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200537 let lines = s:screen_lines(line('.'),20)
538 let expect = [
539 \ " 1234567890 ",
540 \ "~ ",
541 \ "~ ",
542 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100543 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100544 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200545endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100546
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200547func Test_breakindent15_vartabs()
548 if !has("vartabs")
549 return
550 endif
551 let s:input = ""
552 call s:test_windows('setl breakindent briopt= ts=8 sw=8 vts=8')
553 vert resize 30
554 norm! 4a1234567890
555 exe "normal! >>\<C-V>3f0x"
556 let lines = s:screen_lines(line('.'),20)
557 let expect = [
558 \ " 1234567890 ",
559 \ "~ ",
560 \ "~ ",
561 \ ]
562 call s:compare_lines(expect, lines)
563 call s:close_windows('set vts&')
564endfunc
565
566func Test_breakindent16()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100567 " Check that overlong lines are indented correctly.
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200568 let s:input = ""
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100569 call s:test_windows('setl breakindent briopt=min:0 ts=4')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100570 call setline(1, "\t".repeat("1234567890", 10))
571 resize 6
572 norm! 1gg$
573 redraw!
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200574 let lines = s:screen_lines(1,10)
575 let expect = [
576 \ " 789012",
577 \ " 345678",
578 \ " 901234",
579 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100580 call s:compare_lines(expect, lines)
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200581 let lines = s:screen_lines(4,10)
582 let expect = [
583 \ " 567890",
584 \ " 123456",
585 \ " 7890 ",
586 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100587 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100588 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200589endfunc
590
591func Test_breakindent16_vartabs()
592 if !has("vartabs")
593 return
594 endif
595 " Check that overlong lines are indented correctly.
596 let s:input = ""
597 call s:test_windows('setl breakindent briopt=min:0 ts=4 vts=4')
598 call setline(1, "\t".repeat("1234567890", 10))
599 resize 6
600 norm! 1gg$
601 redraw!
602 let lines = s:screen_lines(1,10)
603 let expect = [
604 \ " 789012",
605 \ " 345678",
606 \ " 901234",
607 \ ]
608 call s:compare_lines(expect, lines)
609 let lines = s:screen_lines(4,10)
610 let expect = [
611 \ " 567890",
612 \ " 123456",
613 \ " 7890 ",
614 \ ]
615 call s:compare_lines(expect, lines)
616 call s:close_windows('set vts&')
617endfunc