1" 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 caching gets in its way.
5" It helps to change the tabstop setting and force a redraw (e.g. see
6" Test_breakindent08())
7source check.vim
8CheckOption breakindent
9
10source view_util.vim
11
12let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP"
13
14func s:screen_lines(lnum, width) abort
15  return ScreenLines([a:lnum, a:lnum + 2], a:width)
16endfunc
17
18func s:screen_lines2(lnums, lnume, width) abort
19  return ScreenLines([a:lnums, a:lnume], a:width)
20endfunc
21
22func s:compare_lines(expect, actual)
23  call assert_equal(join(a:expect, "\n"), join(a:actual, "\n"))
24endfunc
25
26func s:test_windows(...)
27  call NewWindow(10, 20)
28  setl ts=4 sw=4 sts=4 breakindent
29  put =s:input
30  exe get(a:000, 0, '')
31endfunc
32
33func s:close_windows(...)
34  call CloseWindow()
35  exe get(a:000, 0, '')
36endfunc
37
38func Test_breakindent01()
39  " simple breakindent test
40  call s:test_windows('setl briopt=min:0')
41  let lines = s:screen_lines(line('.'),8)
42  let expect = [
43	\ "    abcd",
44	\ "    qrst",
45	\ "    GHIJ",
46	\ ]
47  call s:compare_lines(expect, lines)
48  call s:close_windows()
49endfunc
50
51func Test_breakindent01_vartabs()
52  " like 01 but with vartabs feature
53  CheckFeature vartabs
54  call s:test_windows('setl briopt=min:0 vts=4')
55  let lines = s:screen_lines(line('.'),8)
56  let expect = [
57	\ "    abcd",
58	\ "    qrst",
59	\ "    GHIJ",
60	\ ]
61  call s:compare_lines(expect, lines)
62  call s:close_windows('set vts&')
63endfunc
64
65func Test_breakindent02()
66  " simple breakindent test with showbreak set
67  set sbr=>>
68  call s:test_windows('setl briopt=min:0 sbr=')
69  let lines = s:screen_lines(line('.'),8)
70  let expect = [
71	\ "    abcd",
72	\ "    >>qr",
73	\ "    >>EF",
74	\ ]
75  call s:compare_lines(expect, lines)
76  call s:close_windows('set sbr=')
77endfunc
78
79func Test_breakindent02_vartabs()
80  CheckFeature vartabs
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()
94  " simple breakindent test with showbreak set and briopt including sbr
95  call s:test_windows('setl briopt=sbr,min:0 sbr=++')
96  let lines = s:screen_lines(line('.'),8)
97  let expect = [
98	\ "    abcd",
99	\ "++  qrst",
100	\ "++  GHIJ",
101	\ ]
102  call s:compare_lines(expect, lines)
103  " clean up
104  call s:close_windows('set sbr=')
105endfunc
106
107func Test_breakindent03_vartabs()
108  " simple breakindent test with showbreak set and briopt including sbr
109  CheckFeature vartabs
110  call s:test_windows('setl briopt=sbr,min:0 sbr=++ vts=4')
111  let lines = s:screen_lines(line('.'),8)
112  let expect = [
113	\ "    abcd",
114	\ "++  qrst",
115	\ "++  GHIJ",
116	\ ]
117  call s:compare_lines(expect, lines)
118  " clean up
119  call s:close_windows('set sbr= vts&')
120endfunc
121
122func Test_breakindent04()
123  " breakindent set with min width 18
124  set sbr=<<<
125  call s:test_windows('setl sbr=NONE briopt=min:18')
126  let lines = s:screen_lines(line('.'),8)
127  let expect = [
128	\ "    abcd",
129	\ "  qrstuv",
130	\ "  IJKLMN",
131	\ ]
132  call s:compare_lines(expect, lines)
133  " clean up
134  call s:close_windows('set sbr=')
135  set sbr=
136endfunc
137
138func Test_breakindent04_vartabs()
139  " breakindent set with min width 18
140  CheckFeature vartabs
141  call s:test_windows('setl sbr= briopt=min:18 vts=4')
142  let lines = s:screen_lines(line('.'),8)
143  let expect = [
144	\ "    abcd",
145	\ "  qrstuv",
146	\ "  IJKLMN",
147	\ ]
148  call s:compare_lines(expect, lines)
149  " clean up
150  call s:close_windows('set sbr= vts&')
151endfunc
152
153func Test_breakindent05()
154  " breakindent set and shift by 2
155  call s:test_windows('setl briopt=shift:2,min:0')
156  let lines = s:screen_lines(line('.'),8)
157  let expect = [
158	\ "    abcd",
159	\ "      qr",
160	\ "      EF",
161	\ ]
162  call s:compare_lines(expect, lines)
163  call s:close_windows()
164endfunc
165
166func Test_breakindent05_vartabs()
167  " breakindent set and shift by 2
168  CheckFeature vartabs
169  call s:test_windows('setl briopt=shift:2,min:0 vts=4')
170  let lines = s:screen_lines(line('.'),8)
171  let expect = [
172	\ "    abcd",
173	\ "      qr",
174	\ "      EF",
175	\ ]
176  call s:compare_lines(expect, lines)
177  call s:close_windows('set vts&')
178endfunc
179
180func Test_breakindent06()
181  " breakindent set and shift by -1
182  call s:test_windows('setl briopt=shift:-1,min:0')
183  let lines = s:screen_lines(line('.'),8)
184  let expect = [
185	\ "    abcd",
186	\ "   qrstu",
187	\ "   HIJKL",
188	\ ]
189  call s:compare_lines(expect, lines)
190  call s:close_windows()
191endfunc
192
193func Test_breakindent06_vartabs()
194  " breakindent set and shift by -1
195  CheckFeature vartabs
196  call s:test_windows('setl briopt=shift:-1,min:0 vts=4')
197  let lines = s:screen_lines(line('.'),8)
198  let expect = [
199	\ "    abcd",
200	\ "   qrstu",
201	\ "   HIJKL",
202	\ ]
203  call s:compare_lines(expect, lines)
204  call s:close_windows('set vts&')
205endfunc
206
207func Test_breakindent07()
208  " breakindent set and shift by 1, Number  set sbr=? and briopt:sbr
209  call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n')
210  let lines = s:screen_lines(line('.'),10)
211  let expect = [
212	\ "  2     ab",
213	\ "?        m",
214	\ "?        x",
215	\ ]
216  call s:compare_lines(expect, lines)
217  " clean up
218  call s:close_windows('set sbr= cpo-=n')
219endfunc
220
221func Test_breakindent07_vartabs()
222  CheckFeature vartabs
223  " breakindent set and shift by 1, Number  set sbr=? and briopt:sbr
224  call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n vts=4')
225  let lines = s:screen_lines(line('.'),10)
226  let expect = [
227	\ "  2     ab",
228	\ "?        m",
229	\ "?        x",
230	\ ]
231  call s:compare_lines(expect, lines)
232  " clean up
233  call s:close_windows('set sbr= cpo-=n vts&')
234endfunc
235
236func Test_breakindent07a()
237  " breakindent set and shift by 1, Number  set sbr=? and briopt:sbr
238  call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4')
239  let lines = s:screen_lines(line('.'),10)
240  let expect = [
241	\ "  2     ab",
242	\ "    ?    m",
243	\ "    ?    x",
244	\ ]
245  call s:compare_lines(expect, lines)
246  " clean up
247  call s:close_windows('set sbr=')
248endfunc
249
250func Test_breakindent07a_vartabs()
251  CheckFeature vartabs
252  " breakindent set and shift by 1, Number  set sbr=? and briopt:sbr
253  call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 vts=4')
254  let lines = s:screen_lines(line('.'),10)
255  let expect = [
256	\ "  2     ab",
257	\ "    ?    m",
258	\ "    ?    x",
259	\ ]
260  call s:compare_lines(expect, lines)
261  " clean up
262  call s:close_windows('set sbr= vts&')
263endfunc
264
265func Test_breakindent08()
266  " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
267  call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4')
268  " make sure, cache is invalidated!
269  set ts=8
270  redraw!
271  set ts=4
272  redraw!
273  let lines = s:screen_lines(line('.'),10)
274  let expect = [
275	\ "  2 ^Iabcd",
276	\ "#      opq",
277	\ "#      BCD",
278	\ ]
279  call s:compare_lines(expect, lines)
280  call s:close_windows('set sbr= cpo-=n')
281endfunc
282
283func Test_breakindent08_vartabs()
284  CheckFeature vartabs
285  " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
286  call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4 vts=4')
287  " make sure, cache is invalidated!
288  set ts=8
289  redraw!
290  set ts=4
291  redraw!
292  let lines = s:screen_lines(line('.'),10)
293  let expect = [
294	\ "  2 ^Iabcd",
295	\ "#      opq",
296	\ "#      BCD",
297	\ ]
298  call s:compare_lines(expect, lines)
299  call s:close_windows('set sbr= cpo-=n vts&')
300endfunc
301
302func Test_breakindent08a()
303  " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
304  call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list')
305  let lines = s:screen_lines(line('.'),10)
306  let expect = [
307	\ "  2 ^Iabcd",
308	\ "    #  opq",
309	\ "    #  BCD",
310	\ ]
311  call s:compare_lines(expect, lines)
312  call s:close_windows('set sbr=')
313endfunc
314
315func Test_breakindent08a_vartabs()
316  CheckFeature vartabs
317  " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
318  call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list vts=4')
319  let lines = s:screen_lines(line('.'),10)
320  let expect = [
321	\ "  2 ^Iabcd",
322	\ "    #  opq",
323	\ "    #  BCD",
324	\ ]
325  call s:compare_lines(expect, lines)
326  call s:close_windows('set sbr= vts&')
327endfunc
328
329func Test_breakindent09()
330  " breakindent set and shift by 1, Number and list set sbr=#
331  call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list')
332  let lines = s:screen_lines(line('.'),10)
333  let expect = [
334	\ "  2 ^Iabcd",
335	\ "       #op",
336	\ "       #AB",
337	\ ]
338  call s:compare_lines(expect, lines)
339  call s:close_windows('set sbr=')
340endfunc
341
342func Test_breakindent09_vartabs()
343  CheckFeature vartabs
344  " breakindent set and shift by 1, Number and list set sbr=#
345  call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list vts=4')
346  let lines = s:screen_lines(line('.'),10)
347  let expect = [
348	\ "  2 ^Iabcd",
349	\ "       #op",
350	\ "       #AB",
351	\ ]
352  call s:compare_lines(expect, lines)
353  call s:close_windows('set sbr= vts&')
354endfunc
355
356func Test_breakindent10()
357  " breakindent set, Number set sbr=~
358  call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0')
359  " make sure, cache is invalidated!
360  set ts=8
361  redraw!
362  set ts=4
363  redraw!
364  let lines = s:screen_lines(line('.'),10)
365  let expect = [
366	\ "  2     ab",
367	\ "~       mn",
368	\ "~       yz",
369	\ ]
370  call s:compare_lines(expect, lines)
371  call s:close_windows('set sbr= cpo-=n')
372endfunc
373
374func Test_breakindent10_vartabs()
375  CheckFeature vartabs
376  " breakindent set, Number set sbr=~
377  call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0 vts=4')
378  " make sure, cache is invalidated!
379  set ts=8
380  redraw!
381  set ts=4
382  redraw!
383  let lines = s:screen_lines(line('.'),10)
384  let expect = [
385	\ "  2     ab",
386	\ "~       mn",
387	\ "~       yz",
388	\ ]
389  call s:compare_lines(expect, lines)
390  call s:close_windows('set sbr= cpo-=n vts&')
391endfunc
392
393func Test_breakindent11()
394  " test strdisplaywidth()
395  call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4')
396  let text = getline(2)
397  let width = strlen(text[1:]) + indent(2) + strlen(&sbr) * 3 " text wraps 3 times
398  call assert_equal(width, strdisplaywidth(text))
399  call s:close_windows('set sbr=')
400  call assert_equal(4, strdisplaywidth("\t", 4))
401endfunc
402
403func Test_breakindent11_vartabs()
404  CheckFeature vartabs
405  " test strdisplaywidth()
406  call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4')
407  let text = getline(2)
408  let width = strlen(text[1:]) + 2->indent() + strlen(&sbr) * 3 " text wraps 3 times
409  call assert_equal(width, text->strdisplaywidth())
410  call s:close_windows('set sbr= vts&')
411endfunc
412
413func Test_breakindent12()
414  " test breakindent with long indent
415  let s:input = "\t\t\t\t\t{"
416  call s:test_windows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>-')
417  let lines = s:screen_lines(2,16)
418  let expect = [
419	\ " 2 >--->--->--->",
420	\ "          ---{  ",
421	\ "~               ",
422	\ ]
423  call s:compare_lines(expect, lines)
424  call s:close_windows('set nuw=4 listchars=')
425endfunc
426
427func Test_breakindent12_vartabs()
428  CheckFeature vartabs
429  " test breakindent with long indent
430  let s:input = "\t\t\t\t\t{"
431  call s:test_windows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>- vts=4')
432  let lines = s:screen_lines(2,16)
433  let expect = [
434	\ " 2 >--->--->--->",
435	\ "          ---{  ",
436	\ "~               ",
437	\ ]
438  call s:compare_lines(expect, lines)
439  call s:close_windows('set nuw=4 listchars= vts&')
440endfunc
441
442func Test_breakindent13()
443  let s:input = ""
444  call s:test_windows('setl breakindent briopt=min:10 ts=8')
445  vert resize 20
446  call setline(1, ["    a\tb\tc\td\te", "    z   y       x       w       v"])
447  1
448  norm! fbgj"ayl
449  2
450  norm! fygj"byl
451  call assert_equal('d', @a)
452  call assert_equal('w', @b)
453  call s:close_windows()
454endfunc
455
456func Test_breakindent13_vartabs()
457  CheckFeature vartabs
458  let s:input = ""
459  call s:test_windows('setl breakindent briopt=min:10 ts=8 vts=8')
460  vert resize 20
461  call setline(1, ["    a\tb\tc\td\te", "    z   y       x       w       v"])
462  1
463  norm! fbgj"ayl
464  2
465  norm! fygj"byl
466  call assert_equal('d', @a)
467  call assert_equal('w', @b)
468  call s:close_windows('set vts&')
469endfunc
470
471func Test_breakindent14()
472  let s:input = ""
473  call s:test_windows('setl breakindent briopt= ts=8')
474  vert resize 30
475  norm! 3a1234567890
476  norm! a    abcde
477  exec "norm! 0\<C-V>tex"
478  let lines = s:screen_lines(line('.'),8)
479  let expect = [
480	\ "e       ",
481	\ "~       ",
482	\ "~       ",
483	\ ]
484  call s:compare_lines(expect, lines)
485  call s:close_windows()
486endfunc
487
488func Test_breakindent14_vartabs()
489  CheckFeature vartabs
490  let s:input = ""
491  call s:test_windows('setl breakindent briopt= ts=8 vts=8')
492  vert resize 30
493  norm! 3a1234567890
494  norm! a    abcde
495  exec "norm! 0\<C-V>tex"
496  let lines = s:screen_lines(line('.'),8)
497  let expect = [
498	\ "e       ",
499	\ "~       ",
500	\ "~       ",
501	\ ]
502  call s:compare_lines(expect, lines)
503  call s:close_windows('set vts&')
504endfunc
505
506func Test_breakindent15()
507  let s:input = ""
508  call s:test_windows('setl breakindent briopt= ts=8 sw=8')
509  vert resize 30
510  norm! 4a1234567890
511  exe "normal! >>\<C-V>3f0x"
512  let lines = s:screen_lines(line('.'),20)
513  let expect = [
514	\ "        1234567890  ",
515	\ "~                   ",
516	\ "~                   ",
517	\ ]
518  call s:compare_lines(expect, lines)
519  call s:close_windows()
520endfunc
521
522func Test_breakindent15_vartabs()
523  CheckFeature vartabs
524  let s:input = ""
525  call s:test_windows('setl breakindent briopt= ts=8 sw=8 vts=8')
526  vert resize 30
527  norm! 4a1234567890
528  exe "normal! >>\<C-V>3f0x"
529  let lines = s:screen_lines(line('.'),20)
530  let expect = [
531	\ "        1234567890  ",
532	\ "~                   ",
533	\ "~                   ",
534	\ ]
535  call s:compare_lines(expect, lines)
536  call s:close_windows('set vts&')
537endfunc
538
539func Test_breakindent16()
540  " Check that overlong lines are indented correctly.
541  let s:input = ""
542  call s:test_windows('setl breakindent briopt=min:0 ts=4')
543  call setline(1, "\t".repeat("1234567890", 10))
544  resize 6
545  norm! 1gg$
546  redraw!
547  let lines = s:screen_lines(1,10)
548  let expect = [
549	\ "    789012",
550	\ "    345678",
551	\ "    901234",
552	\ ]
553  call s:compare_lines(expect, lines)
554  let lines = s:screen_lines(4,10)
555  let expect = [
556	\ "    567890",
557	\ "    123456",
558	\ "    7890  ",
559	\ ]
560  call s:compare_lines(expect, lines)
561  call s:close_windows()
562endfunc
563
564func Test_breakindent16_vartabs()
565  CheckFeature vartabs
566  " Check that overlong lines are indented correctly.
567  let s:input = ""
568  call s:test_windows('setl breakindent briopt=min:0 ts=4 vts=4')
569  call setline(1, "\t".repeat("1234567890", 10))
570  resize 6
571  norm! 1gg$
572  redraw!
573  let lines = s:screen_lines(1,10)
574  let expect = [
575	\ "    789012",
576	\ "    345678",
577	\ "    901234",
578	\ ]
579  call s:compare_lines(expect, lines)
580  let lines = s:screen_lines(4,10)
581  let expect = [
582	\ "    567890",
583	\ "    123456",
584	\ "    7890  ",
585	\ ]
586  call s:compare_lines(expect, lines)
587  call s:close_windows('set vts&')
588endfunc
589
590func Test_breakindent17_vartabs()
591  CheckFeature vartabs
592  let s:input = ""
593  call s:test_windows('setl breakindent list listchars=tab:<-> showbreak=+++')
594  call setline(1, "\t" . repeat('a', 63))
595  vert resize 30
596  norm! 1gg$
597  redraw!
598  let lines = s:screen_lines(1, 30)
599  let expect = [
600	\ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa",
601	\ "    +++aaaaaaaaaaaaaaaaaaaaaaa",
602	\ "    +++aaaaaaaaaaaaaa         ",
603	\ ]
604  call s:compare_lines(expect, lines)
605  call s:close_windows('set breakindent& list& listchars& showbreak&')
606endfunc
607
608func Test_breakindent18_vartabs()
609  CheckFeature vartabs
610  let s:input = ""
611  call s:test_windows('setl breakindent list listchars=tab:<->')
612  call setline(1, "\t" . repeat('a', 63))
613  vert resize 30
614  norm! 1gg$
615  redraw!
616  let lines = s:screen_lines(1, 30)
617  let expect = [
618	\ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa",
619	\ "    aaaaaaaaaaaaaaaaaaaaaaaaaa",
620	\ "    aaaaaaaaaaa               ",
621	\ ]
622  call s:compare_lines(expect, lines)
623  call s:close_windows('set breakindent& list& listchars&')
624endfunc
625
626func Test_breakindent19_sbr_nextpage()
627  let s:input = ""
628  call s:test_windows('setl breakindent briopt=shift:2,sbr,min:18 sbr=>')
629  call setline(1, repeat('a', 200))
630  norm! 1gg
631  redraw!
632  let lines = s:screen_lines(1, 20)
633  let expect = [
634	\ "aaaaaaaaaaaaaaaaaaaa",
635	\ "> aaaaaaaaaaaaaaaaaa",
636	\ "> aaaaaaaaaaaaaaaaaa",
637	\ ]
638  call s:compare_lines(expect, lines)
639  " Scroll down one screen line
640  setl scrolloff=5
641  norm! 5gj
642  let lines = s:screen_lines(1, 20)
643  let expect = [
644	\ "aaaaaaaaaaaaaaaaaaaa",
645	\ "> aaaaaaaaaaaaaaaaaa",
646	\ "> aaaaaaaaaaaaaaaaaa",
647	\ ]
648  call s:compare_lines(expect, lines)
649  redraw!
650  " moving the cursor doesn't change the text offset
651  norm! l
652  redraw!
653  let lines = s:screen_lines(1, 20)
654  call s:compare_lines(expect, lines)
655
656  setl breakindent briopt=min:18 sbr=>
657  norm! 5gj
658  let lines = s:screen_lines(1, 20)
659  let expect = [
660	\ ">aaaaaaaaaaaaaaaaaaa",
661	\ ">aaaaaaaaaaaaaaaaaaa",
662	\ ">aaaaaaaaaaaaaaaaaaa",
663	\ ]
664  call s:compare_lines(expect, lines)
665  call s:close_windows('set breakindent& briopt& sbr&')
666endfunc
667
668func Test_breakindent20_cpo_n_nextpage()
669  let s:input = ""
670  call s:test_windows('setl breakindent briopt=min:14 cpo+=n number')
671  call setline(1, repeat('a', 200))
672  norm! 1gg
673  redraw!
674  let lines = s:screen_lines(1, 20)
675  let expect = [
676	\ "  1 aaaaaaaaaaaaaaaa",
677	\ "    aaaaaaaaaaaaaaaa",
678	\ "    aaaaaaaaaaaaaaaa",
679	\ ]
680  call s:compare_lines(expect, lines)
681  " Scroll down one screen line
682  setl scrolloff=5
683  norm! 5gj
684  redraw!
685  let lines = s:screen_lines(1, 20)
686  let expect = [
687	\ "--1 aaaaaaaaaaaaaaaa",
688	\ "    aaaaaaaaaaaaaaaa",
689	\ "    aaaaaaaaaaaaaaaa",
690	\ ]
691  call s:compare_lines(expect, lines)
692
693  setl briopt+=shift:2
694  norm! 1gg
695  let lines = s:screen_lines(1, 20)
696  let expect = [
697	\ "  1 aaaaaaaaaaaaaaaa",
698	\ "      aaaaaaaaaaaaaa",
699	\ "      aaaaaaaaaaaaaa",
700	\ ]
701  call s:compare_lines(expect, lines)
702  " Scroll down one screen line
703  norm! 5gj
704  let lines = s:screen_lines(1, 20)
705  let expect = [
706	\ "--1   aaaaaaaaaaaaaa",
707	\ "      aaaaaaaaaaaaaa",
708	\ "      aaaaaaaaaaaaaa",
709	\ ]
710  call s:compare_lines(expect, lines)
711
712  call s:close_windows('set breakindent& briopt& cpo& number&')
713endfunc
714
715func Test_breakindent20_list()
716  call s:test_windows('setl breakindent breakindentopt= linebreak')
717  " default:
718  call setline(1, ['  1.  Congress shall make no law',
719        \ '  2.) Congress shall make no law',
720        \ '  3.] Congress shall make no law'])
721  norm! 1gg
722  redraw!
723  let lines = s:screen_lines2(1, 6, 20)
724  let expect = [
725	\ "  1.  Congress      ",
726	\ "shall make no law   ",
727	\ "  2.) Congress      ",
728	\ "shall make no law   ",
729	\ "  3.] Congress      ",
730	\ "shall make no law   ",
731	\ ]
732  call s:compare_lines(expect, lines)
733  " set mininum indent
734  setl briopt=min:5
735  redraw!
736  let lines = s:screen_lines2(1, 6, 20)
737  let expect = [
738	\ "  1.  Congress      ",
739	\ "  shall make no law ",
740	\ "  2.) Congress      ",
741	\ "  shall make no law ",
742	\ "  3.] Congress      ",
743	\ "  shall make no law ",
744	\ ]
745  call s:compare_lines(expect, lines)
746  " set additional handing indent
747  setl briopt+=list:4
748  redraw!
749  let expect = [
750	\ "  1.  Congress      ",
751	\ "      shall make no ",
752	\ "      law           ",
753	\ "  2.) Congress      ",
754	\ "      shall make no ",
755	\ "      law           ",
756	\ "  3.] Congress      ",
757	\ "      shall make no ",
758	\ "      law           ",
759	\ ]
760  let lines = s:screen_lines2(1, 9, 20)
761  call s:compare_lines(expect, lines)
762
763  " reset linebreak option
764  " Note: it indents by one additional
765  " space, because of the leading space.
766  setl linebreak&vim list listchars=eol:$,space:_
767  redraw!
768  let expect = [
769	\ "__1.__Congress_shall",
770	\ "      _make_no_law$ ",
771	\ "__2.)_Congress_shall",
772	\ "      _make_no_law$ ",
773	\ "__3.]_Congress_shall",
774	\ "      _make_no_law$ ",
775	\ ]
776  let lines = s:screen_lines2(1, 6, 20)
777  call s:compare_lines(expect, lines)
778
779  " check formatlistpat indent
780  setl briopt=min:5,list:-1
781  setl linebreak list&vim listchars&vim
782  let &l:flp = '^\s*\d\+\.\?[\]:)}\t ]\s*'
783  redraw!
784  let expect = [
785	\ "  1.  Congress      ",
786	\ "      shall make no ",
787	\ "      law           ",
788	\ "  2.) Congress      ",
789	\ "      shall make no ",
790	\ "      law           ",
791	\ "  3.] Congress      ",
792	\ "      shall make no ",
793	\ "      law           ",
794	\ ]
795  let lines = s:screen_lines2(1, 9, 20)
796  call s:compare_lines(expect, lines)
797  " check formatlistpat indent with different list levels
798  let &l:flp = '^\s*\*\+\s\+'
799  redraw!
800  %delete _
801  call setline(1, ['* Congress shall make no law',
802        \ '*** Congress shall make no law',
803        \ '**** Congress shall make no law'])
804  norm! 1gg
805  let expect = [
806	\ "* Congress shall    ",
807	\ "  make no law       ",
808	\ "*** Congress shall  ",
809	\ "    make no law     ",
810	\ "**** Congress shall ",
811	\ "     make no law    ",
812	\ ]
813  let lines = s:screen_lines2(1, 6, 20)
814  call s:compare_lines(expect, lines)
815
816  " check formatlistpat indent with different list level
817  " showbreak and sbr
818  setl briopt=min:5,sbr,list:-1,shift:2
819  setl showbreak=>
820  redraw!
821  let expect = [
822	\ "* Congress shall    ",
823	\ "> make no law       ",
824	\ "*** Congress shall  ",
825	\ ">   make no law     ",
826	\ "**** Congress shall ",
827	\ ">    make no law    ",
828	\ ]
829  let lines = s:screen_lines2(1, 6, 20)
830  call s:compare_lines(expect, lines)
831  call s:close_windows('set breakindent& briopt& linebreak& list& listchars& showbreak&')
832endfunc
833
834" The following used to crash Vim. This is fixed by 8.2.3391.
835" This is a regression introduced by 8.2.2903.
836func Test_window_resize_with_linebreak()
837  new
838  53vnew
839  set linebreak
840  set showbreak=>>
841  set breakindent
842  set breakindentopt=shift:4
843  call setline(1, "\naaaaaaaaa\n\na\naaaaa\n¯aaaaaaaaaa\naaaaaaaaaaaa\naaa\n\"a:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - aaaaaaaa\"\naaaaaaaa\n\"a")
844  redraw!
845  call assert_equal(["    >>aa^@\"a: "], ScreenLines(2, 14))
846  vertical resize 52
847  redraw!
848  call assert_equal(["    >>aaa^@\"a:"], ScreenLines(2, 14))
849  %bw!
850endfunc
851
852" vim: shiftwidth=2 sts=2 expandtab
853