blob: 65e258af54144da177078f0baa47b8b60c0de4ce [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())
Bram Moolenaar8c5a2782019-08-07 23:07:07 +02007source check.vim
8CheckOption breakindent
Bram Moolenaar6c896862016-11-17 19:46:51 +01009
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010010source view_util.vim
11
Bram Moolenaar6c896862016-11-17 19:46:51 +010012let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP"
13
Bram Moolenaar04958cb2018-06-23 19:23:02 +020014func s:screen_lines(lnum, width) abort
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010015 return ScreenLines([a:lnum, a:lnum + 2], a:width)
Bram Moolenaar04958cb2018-06-23 19:23:02 +020016endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +010017
Bram Moolenaar04958cb2018-06-23 19:23:02 +020018func s:compare_lines(expect, actual)
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010019 call assert_equal(join(a:expect, "\n"), join(a:actual, "\n"))
Bram Moolenaar04958cb2018-06-23 19:23:02 +020020endfunc
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010021
Bram Moolenaar04958cb2018-06-23 19:23:02 +020022func s:test_windows(...)
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010023 call NewWindow(10, 20)
24 setl ts=4 sw=4 sts=4 breakindent
Bram Moolenaar6c896862016-11-17 19:46:51 +010025 put =s:input
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010026 exe get(a:000, 0, '')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020027endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +010028
Bram Moolenaar04958cb2018-06-23 19:23:02 +020029func s:close_windows(...)
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010030 call CloseWindow()
31 exe get(a:000, 0, '')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020032endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +010033
Bram Moolenaar04958cb2018-06-23 19:23:02 +020034func Test_breakindent01()
Bram Moolenaar6c896862016-11-17 19:46:51 +010035 " simple breakindent test
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010036 call s:test_windows('setl briopt=min:0')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020037 let lines = s:screen_lines(line('.'),8)
38 let expect = [
39 \ " abcd",
40 \ " qrst",
41 \ " GHIJ",
42 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010043 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +010044 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +020045endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +010046
Bram Moolenaar04958cb2018-06-23 19:23:02 +020047func Test_breakindent01_vartabs()
48 " like 01 but with vartabs feature
49 if !has("vartabs")
50 return
51 endif
52 call s:test_windows('setl briopt=min:0 vts=4')
53 let lines = s:screen_lines(line('.'),8)
54 let expect = [
55 \ " abcd",
56 \ " qrst",
57 \ " GHIJ",
58 \ ]
59 call s:compare_lines(expect, lines)
60 call s:close_windows('set vts&')
61endfunc
62
63func Test_breakindent02()
Bram Moolenaar6c896862016-11-17 19:46:51 +010064 " simple breakindent test with showbreak set
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010065 call s:test_windows('setl briopt=min:0 sbr=>>')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020066 let lines = s:screen_lines(line('.'),8)
67 let expect = [
68 \ " abcd",
69 \ " >>qr",
70 \ " >>EF",
71 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010072 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +010073 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020074endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +010075
Bram Moolenaar04958cb2018-06-23 19:23:02 +020076func Test_breakindent02_vartabs()
77 if !has("vartabs")
78 return
79 endif
80 " simple breakindent test with showbreak set
81 call s:test_windows('setl briopt=min:0 sbr=>> vts=4')
82 let lines = s:screen_lines(line('.'),8)
83 let expect = [
84 \ " abcd",
85 \ " >>qr",
86 \ " >>EF",
87 \ ]
88 call s:compare_lines(expect, lines)
89 call s:close_windows('set sbr= vts&')
90endfunc
91
92func Test_breakindent03()
Bram Moolenaar6c896862016-11-17 19:46:51 +010093 " simple breakindent test with showbreak set and briopt including sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010094 call s:test_windows('setl briopt=sbr,min:0 sbr=++')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020095 let lines = s:screen_lines(line('.'),8)
96 let expect = [
97 \ " abcd",
98 \ "++ qrst",
99 \ "++ GHIJ",
100 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100101 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100102 " clean up
103 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200104endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100105
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200106func Test_breakindent03_vartabs()
107 " simple breakindent test with showbreak set and briopt including sbr
108 if !has("vartabs")
109 return
110 endif
111 call s:test_windows('setl briopt=sbr,min:0 sbr=++ vts=4')
112 let lines = s:screen_lines(line('.'),8)
113 let expect = [
114 \ " abcd",
115 \ "++ qrst",
116 \ "++ GHIJ",
117 \ ]
118 call s:compare_lines(expect, lines)
119 " clean up
120 call s:close_windows('set sbr= vts&')
121endfunc
122
123func Test_breakindent04()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100124 " breakindent set with min width 18
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100125 call s:test_windows('setl sbr= briopt=min:18')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200126 let lines = s:screen_lines(line('.'),8)
127 let expect = [
128 \ " abcd",
129 \ " qrstuv",
130 \ " IJKLMN",
131 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100132 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100133 " clean up
134 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200135endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100136
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200137func Test_breakindent04_vartabs()
138 " breakindent set with min width 18
139 if !has("vartabs")
140 return
141 endif
142 call s:test_windows('setl sbr= briopt=min:18 vts=4')
143 let lines = s:screen_lines(line('.'),8)
144 let expect = [
145 \ " abcd",
146 \ " qrstuv",
147 \ " IJKLMN",
148 \ ]
149 call s:compare_lines(expect, lines)
150 " clean up
151 call s:close_windows('set sbr= vts&')
152endfunc
153
154func Test_breakindent05()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100155 " breakindent set and shift by 2
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100156 call s:test_windows('setl briopt=shift:2,min:0')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200157 let lines = s:screen_lines(line('.'),8)
158 let expect = [
159 \ " abcd",
160 \ " qr",
161 \ " EF",
162 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100163 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100164 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200165endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100166
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200167func Test_breakindent05_vartabs()
168 " breakindent set and shift by 2
169 if !has("vartabs")
170 return
171 endif
172 call s:test_windows('setl briopt=shift:2,min:0 vts=4')
173 let lines = s:screen_lines(line('.'),8)
174 let expect = [
175 \ " abcd",
176 \ " qr",
177 \ " EF",
178 \ ]
179 call s:compare_lines(expect, lines)
180 call s:close_windows('set vts&')
181endfunc
182
183func Test_breakindent06()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100184 " breakindent set and shift by -1
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100185 call s:test_windows('setl briopt=shift:-1,min:0')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200186 let lines = s:screen_lines(line('.'),8)
187 let expect = [
188 \ " abcd",
189 \ " qrstu",
190 \ " HIJKL",
191 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100192 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100193 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200194endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100195
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200196func Test_breakindent06_vartabs()
197 " breakindent set and shift by -1
198 if !has("vartabs")
199 return
200 endif
201 call s:test_windows('setl briopt=shift:-1,min:0 vts=4')
202 let lines = s:screen_lines(line('.'),8)
203 let expect = [
204 \ " abcd",
205 \ " qrstu",
206 \ " HIJKL",
207 \ ]
208 call s:compare_lines(expect, lines)
209 call s:close_windows('set vts&')
210endfunc
211
212func Test_breakindent07()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100213 " breakindent set and shift by 1, Number set sbr=? and briopt:sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100214 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200215 let lines = s:screen_lines(line('.'),10)
216 let expect = [
217 \ " 2 ab",
218 \ "? m",
219 \ "? x",
220 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100221 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100222 " clean up
223 call s:close_windows('set sbr= cpo-=n')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200224endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100225
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200226func Test_breakindent07_vartabs()
227 if !has("vartabs")
228 return
229 endif
230 " breakindent set and shift by 1, Number set sbr=? and briopt:sbr
231 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n vts=4')
232 let lines = s:screen_lines(line('.'),10)
233 let expect = [
234 \ " 2 ab",
235 \ "? m",
236 \ "? x",
237 \ ]
238 call s:compare_lines(expect, lines)
239 " clean up
240 call s:close_windows('set sbr= cpo-=n vts&')
241endfunc
242
243func Test_breakindent07a()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100244 " breakindent set and shift by 1, Number set sbr=? and briopt:sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100245 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200246 let lines = s:screen_lines(line('.'),10)
247 let expect = [
248 \ " 2 ab",
249 \ " ? m",
250 \ " ? x",
251 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100252 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100253 " clean up
254 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200255endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100256
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200257func Test_breakindent07a_vartabs()
258 if !has("vartabs")
259 return
260 endif
261 " breakindent set and shift by 1, Number set sbr=? and briopt:sbr
262 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 vts=4')
263 let lines = s:screen_lines(line('.'),10)
264 let expect = [
265 \ " 2 ab",
266 \ " ? m",
267 \ " ? x",
268 \ ]
269 call s:compare_lines(expect, lines)
270 " clean up
271 call s:close_windows('set sbr= vts&')
272endfunc
273
274func Test_breakindent08()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100275 " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100276 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 +0100277 " make sure, cache is invalidated!
278 set ts=8
279 redraw!
280 set ts=4
281 redraw!
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200282 let lines = s:screen_lines(line('.'),10)
283 let expect = [
284 \ " 2 ^Iabcd",
285 \ "# opq",
286 \ "# BCD",
287 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100288 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100289 call s:close_windows('set sbr= cpo-=n')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200290endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100291
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200292func Test_breakindent08_vartabs()
293 if !has("vartabs")
294 return
295 endif
296 " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
297 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4 vts=4')
298 " make sure, cache is invalidated!
299 set ts=8
300 redraw!
301 set ts=4
302 redraw!
303 let lines = s:screen_lines(line('.'),10)
304 let expect = [
305 \ " 2 ^Iabcd",
306 \ "# opq",
307 \ "# BCD",
308 \ ]
309 call s:compare_lines(expect, lines)
310 call s:close_windows('set sbr= cpo-=n vts&')
311endfunc
312
313func Test_breakindent08a()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100314 " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100315 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200316 let lines = s:screen_lines(line('.'),10)
317 let expect = [
318 \ " 2 ^Iabcd",
319 \ " # opq",
320 \ " # BCD",
321 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100322 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100323 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200324endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100325
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200326func Test_breakindent08a_vartabs()
327 if !has("vartabs")
328 return
329 endif
330 " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
331 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list vts=4')
332 let lines = s:screen_lines(line('.'),10)
333 let expect = [
334 \ " 2 ^Iabcd",
335 \ " # opq",
336 \ " # BCD",
337 \ ]
338 call s:compare_lines(expect, lines)
339 call s:close_windows('set sbr= vts&')
340endfunc
341
342func Test_breakindent09()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100343 " breakindent set and shift by 1, Number and list set sbr=#
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100344 call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200345 let lines = s:screen_lines(line('.'),10)
346 let expect = [
347 \ " 2 ^Iabcd",
348 \ " #op",
349 \ " #AB",
350 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100351 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100352 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200353endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100354
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200355func Test_breakindent09_vartabs()
356 if !has("vartabs")
357 return
358 endif
359 " breakindent set and shift by 1, Number and list set sbr=#
360 call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list vts=4')
361 let lines = s:screen_lines(line('.'),10)
362 let expect = [
363 \ " 2 ^Iabcd",
364 \ " #op",
365 \ " #AB",
366 \ ]
367 call s:compare_lines(expect, lines)
368 call s:close_windows('set sbr= vts&')
369endfunc
370
371func Test_breakindent10()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100372 " breakindent set, Number set sbr=~
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100373 call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100374 " make sure, cache is invalidated!
375 set ts=8
376 redraw!
377 set ts=4
378 redraw!
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200379 let lines = s:screen_lines(line('.'),10)
380 let expect = [
381 \ " 2 ab",
382 \ "~ mn",
383 \ "~ yz",
384 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100385 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100386 call s:close_windows('set sbr= cpo-=n')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200387endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100388
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200389func Test_breakindent10_vartabs()
390 if !has("vartabs")
391 return
392 endif
393 " breakindent set, Number set sbr=~
394 call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0 vts=4')
395 " make sure, cache is invalidated!
396 set ts=8
397 redraw!
398 set ts=4
399 redraw!
400 let lines = s:screen_lines(line('.'),10)
401 let expect = [
402 \ " 2 ab",
403 \ "~ mn",
404 \ "~ yz",
405 \ ]
406 call s:compare_lines(expect, lines)
407 call s:close_windows('set sbr= cpo-=n vts&')
408endfunc
409
410func Test_breakindent11()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100411 " test strdisplaywidth()
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100412 call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200413 let text = getline(2)
Bram Moolenaarf9f24ce2019-08-31 21:17:39 +0200414 let width = strlen(text[1:]) + indent(2) + strlen(&sbr) * 3 " text wraps 3 times
Bram Moolenaar6c896862016-11-17 19:46:51 +0100415 call assert_equal(width, strdisplaywidth(text))
416 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200417endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100418
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200419func Test_breakindent11_vartabs()
420 if !has("vartabs")
421 return
422 endif
423 " test strdisplaywidth()
424 call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4')
425 let text = getline(2)
Bram Moolenaarf9f24ce2019-08-31 21:17:39 +0200426 let width = strlen(text[1:]) + 2->indent() + strlen(&sbr) * 3 " text wraps 3 times
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200427 call assert_equal(width, strdisplaywidth(text))
428 call s:close_windows('set sbr= vts&')
429endfunc
430
431func Test_breakindent12()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100432 " test breakindent with long indent
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200433 let s:input = "\t\t\t\t\t{"
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100434 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 +0200435 let lines = s:screen_lines(2,16)
436 let expect = [
437 \ " 2 >--->--->--->",
438 \ " ---{ ",
439 \ "~ ",
440 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100441 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100442 call s:close_windows('set nuw=4 listchars=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200443endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100444
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200445func Test_breakindent12_vartabs()
446 if !has("vartabs")
447 return
448 endif
449 " test breakindent with long indent
450 let s:input = "\t\t\t\t\t{"
451 call s:test_windows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>- vts=4')
452 let lines = s:screen_lines(2,16)
453 let expect = [
454 \ " 2 >--->--->--->",
455 \ " ---{ ",
456 \ "~ ",
457 \ ]
458 call s:compare_lines(expect, lines)
459 call s:close_windows('set nuw=4 listchars= vts&')
460endfunc
461
462func Test_breakindent13()
463 let s:input = ""
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100464 call s:test_windows('setl breakindent briopt=min:10 ts=8')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100465 vert resize 20
466 call setline(1, [" a\tb\tc\td\te", " z y x w v"])
467 1
468 norm! fbgj"ayl
469 2
470 norm! fygj"byl
471 call assert_equal('d', @a)
472 call assert_equal('w', @b)
473 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200474endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100475
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200476func Test_breakindent13_vartabs()
477 if !has("vartabs")
478 return
479 endif
480 let s:input = ""
481 call s:test_windows('setl breakindent briopt=min:10 ts=8 vts=8')
482 vert resize 20
483 call setline(1, [" a\tb\tc\td\te", " z y x w v"])
484 1
485 norm! fbgj"ayl
486 2
487 norm! fygj"byl
488 call assert_equal('d', @a)
489 call assert_equal('w', @b)
490 call s:close_windows('set vts&')
491endfunc
492
493func Test_breakindent14()
494 let s:input = ""
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100495 call s:test_windows('setl breakindent briopt= ts=8')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100496 vert resize 30
497 norm! 3a1234567890
498 norm! a abcde
499 exec "norm! 0\<C-V>tex"
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200500 let lines = s:screen_lines(line('.'),8)
501 let expect = [
502 \ "e ",
503 \ "~ ",
504 \ "~ ",
505 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100506 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100507 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200508endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100509
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200510func Test_breakindent14_vartabs()
511 if !has("vartabs")
512 return
513 endif
514 let s:input = ""
515 call s:test_windows('setl breakindent briopt= ts=8 vts=8')
516 vert resize 30
517 norm! 3a1234567890
518 norm! a abcde
519 exec "norm! 0\<C-V>tex"
520 let lines = s:screen_lines(line('.'),8)
521 let expect = [
522 \ "e ",
523 \ "~ ",
524 \ "~ ",
525 \ ]
526 call s:compare_lines(expect, lines)
527 call s:close_windows('set vts&')
528endfunc
529
530func Test_breakindent15()
531 let s:input = ""
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100532 call s:test_windows('setl breakindent briopt= ts=8 sw=8')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100533 vert resize 30
534 norm! 4a1234567890
535 exe "normal! >>\<C-V>3f0x"
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200536 let lines = s:screen_lines(line('.'),20)
537 let expect = [
538 \ " 1234567890 ",
539 \ "~ ",
540 \ "~ ",
541 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100542 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100543 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200544endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100545
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200546func Test_breakindent15_vartabs()
547 if !has("vartabs")
548 return
549 endif
550 let s:input = ""
551 call s:test_windows('setl breakindent briopt= ts=8 sw=8 vts=8')
552 vert resize 30
553 norm! 4a1234567890
554 exe "normal! >>\<C-V>3f0x"
555 let lines = s:screen_lines(line('.'),20)
556 let expect = [
557 \ " 1234567890 ",
558 \ "~ ",
559 \ "~ ",
560 \ ]
561 call s:compare_lines(expect, lines)
562 call s:close_windows('set vts&')
563endfunc
564
565func Test_breakindent16()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100566 " Check that overlong lines are indented correctly.
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200567 let s:input = ""
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100568 call s:test_windows('setl breakindent briopt=min:0 ts=4')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100569 call setline(1, "\t".repeat("1234567890", 10))
570 resize 6
571 norm! 1gg$
572 redraw!
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200573 let lines = s:screen_lines(1,10)
574 let expect = [
575 \ " 789012",
576 \ " 345678",
577 \ " 901234",
578 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100579 call s:compare_lines(expect, lines)
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200580 let lines = s:screen_lines(4,10)
581 let expect = [
582 \ " 567890",
583 \ " 123456",
584 \ " 7890 ",
585 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100586 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100587 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200588endfunc
589
590func Test_breakindent16_vartabs()
591 if !has("vartabs")
592 return
593 endif
594 " Check that overlong lines are indented correctly.
595 let s:input = ""
596 call s:test_windows('setl breakindent briopt=min:0 ts=4 vts=4')
597 call setline(1, "\t".repeat("1234567890", 10))
598 resize 6
599 norm! 1gg$
600 redraw!
601 let lines = s:screen_lines(1,10)
602 let expect = [
603 \ " 789012",
604 \ " 345678",
605 \ " 901234",
606 \ ]
607 call s:compare_lines(expect, lines)
608 let lines = s:screen_lines(4,10)
609 let expect = [
610 \ " 567890",
611 \ " 123456",
612 \ " 7890 ",
613 \ ]
614 call s:compare_lines(expect, lines)
615 call s:close_windows('set vts&')
616endfunc