blob: 9b6106d7be7c9c1e1a6d9fd2cb026f92a07bdc69 [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
Bram Moolenaar4b96df52020-01-26 22:00:26 +01004" while the test is run, the breakindent caching 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
Bram Moolenaar21efafe2022-03-03 20:04:03 +000011source screendump.vim
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010012
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
Christian Brabandt4a0b85a2021-07-14 20:00:27 +020019func s:screen_lines2(lnums, lnume, width) abort
20 return ScreenLines([a:lnums, a:lnume], a:width)
21endfunc
22
Bram Moolenaar04958cb2018-06-23 19:23:02 +020023func s:compare_lines(expect, actual)
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010024 call assert_equal(join(a:expect, "\n"), join(a:actual, "\n"))
Bram Moolenaar04958cb2018-06-23 19:23:02 +020025endfunc
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010026
Bram Moolenaar04958cb2018-06-23 19:23:02 +020027func s:test_windows(...)
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010028 call NewWindow(10, 20)
29 setl ts=4 sw=4 sts=4 breakindent
Bram Moolenaar6c896862016-11-17 19:46:51 +010030 put =s:input
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010031 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 s:close_windows(...)
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010035 call CloseWindow()
36 exe get(a:000, 0, '')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020037endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +010038
Bram Moolenaar04958cb2018-06-23 19:23:02 +020039func Test_breakindent01()
Bram Moolenaar6c896862016-11-17 19:46:51 +010040 " simple breakindent test
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010041 call s:test_windows('setl briopt=min:0')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020042 let lines = s:screen_lines(line('.'),8)
43 let expect = [
44 \ " abcd",
45 \ " qrst",
46 \ " GHIJ",
47 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010048 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +010049 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +020050endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +010051
Bram Moolenaar04958cb2018-06-23 19:23:02 +020052func Test_breakindent01_vartabs()
53 " like 01 but with vartabs feature
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020054 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +020055 call s:test_windows('setl briopt=min:0 vts=4')
56 let lines = s:screen_lines(line('.'),8)
57 let expect = [
58 \ " abcd",
59 \ " qrst",
60 \ " GHIJ",
61 \ ]
62 call s:compare_lines(expect, lines)
63 call s:close_windows('set vts&')
64endfunc
65
66func Test_breakindent02()
Bram Moolenaar6c896862016-11-17 19:46:51 +010067 " simple breakindent test with showbreak set
Bram Moolenaaree857022019-11-09 23:26:40 +010068 set sbr=>>
69 call s:test_windows('setl briopt=min:0 sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020070 let lines = s:screen_lines(line('.'),8)
71 let expect = [
72 \ " abcd",
73 \ " >>qr",
74 \ " >>EF",
75 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010076 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +010077 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020078endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +010079
Bram Moolenaar04958cb2018-06-23 19:23:02 +020080func Test_breakindent02_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020081 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +020082 " simple breakindent test with showbreak set
83 call s:test_windows('setl briopt=min:0 sbr=>> vts=4')
84 let lines = s:screen_lines(line('.'),8)
85 let expect = [
86 \ " abcd",
87 \ " >>qr",
88 \ " >>EF",
89 \ ]
90 call s:compare_lines(expect, lines)
91 call s:close_windows('set sbr= vts&')
92endfunc
93
94func Test_breakindent03()
Bram Moolenaar6c896862016-11-17 19:46:51 +010095 " simple breakindent test with showbreak set and briopt including sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +010096 call s:test_windows('setl briopt=sbr,min:0 sbr=++')
Bram Moolenaar04958cb2018-06-23 19:23:02 +020097 let lines = s:screen_lines(line('.'),8)
98 let expect = [
99 \ " abcd",
100 \ "++ qrst",
101 \ "++ GHIJ",
102 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100103 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100104 " clean up
105 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200106endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100107
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200108func Test_breakindent03_vartabs()
109 " simple breakindent test with showbreak set and briopt including sbr
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200110 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200111 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 Moolenaaree857022019-11-09 23:26:40 +0100125 set sbr=<<<
126 call s:test_windows('setl sbr=NONE 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 Moolenaaree857022019-11-09 23:26:40 +0100136 set sbr=
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200137endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100138
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200139func Test_breakindent04_vartabs()
140 " breakindent set with min width 18
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200141 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200142 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
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200169 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200170 call s:test_windows('setl briopt=shift:2,min:0 vts=4')
171 let lines = s:screen_lines(line('.'),8)
172 let expect = [
173 \ " abcd",
174 \ " qr",
175 \ " EF",
176 \ ]
177 call s:compare_lines(expect, lines)
178 call s:close_windows('set vts&')
179endfunc
180
181func Test_breakindent06()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100182 " breakindent set and shift by -1
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100183 call s:test_windows('setl briopt=shift:-1,min:0')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200184 let lines = s:screen_lines(line('.'),8)
185 let expect = [
186 \ " abcd",
187 \ " qrstu",
188 \ " HIJKL",
189 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100190 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100191 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200192endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100193
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200194func Test_breakindent06_vartabs()
195 " breakindent set and shift by -1
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200196 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200197 call s:test_windows('setl briopt=shift:-1,min:0 vts=4')
198 let lines = s:screen_lines(line('.'),8)
199 let expect = [
200 \ " abcd",
201 \ " qrstu",
202 \ " HIJKL",
203 \ ]
204 call s:compare_lines(expect, lines)
205 call s:close_windows('set vts&')
206endfunc
207
208func Test_breakindent07()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100209 " breakindent set and shift by 1, Number set sbr=? and briopt:sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100210 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200211 let lines = s:screen_lines(line('.'),10)
212 let expect = [
213 \ " 2 ab",
214 \ "? m",
215 \ "? x",
216 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100217 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100218 " clean up
219 call s:close_windows('set sbr= cpo-=n')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200220endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100221
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200222func Test_breakindent07_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200223 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200224 " breakindent set and shift by 1, Number set sbr=? and briopt:sbr
225 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n vts=4')
226 let lines = s:screen_lines(line('.'),10)
227 let expect = [
228 \ " 2 ab",
229 \ "? m",
230 \ "? x",
231 \ ]
232 call s:compare_lines(expect, lines)
233 " clean up
234 call s:close_windows('set sbr= cpo-=n vts&')
235endfunc
236
237func Test_breakindent07a()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100238 " breakindent set and shift by 1, Number set sbr=? and briopt:sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100239 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200240 let lines = s:screen_lines(line('.'),10)
241 let expect = [
242 \ " 2 ab",
243 \ " ? m",
244 \ " ? x",
245 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100246 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100247 " clean up
248 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200249endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100250
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200251func Test_breakindent07a_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200252 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200253 " breakindent set and shift by 1, Number set sbr=? and briopt:sbr
254 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 vts=4')
255 let lines = s:screen_lines(line('.'),10)
256 let expect = [
257 \ " 2 ab",
258 \ " ? m",
259 \ " ? x",
260 \ ]
261 call s:compare_lines(expect, lines)
262 " clean up
263 call s:close_windows('set sbr= vts&')
264endfunc
265
266func Test_breakindent08()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100267 " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100268 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 +0100269 " make sure, cache is invalidated!
270 set ts=8
271 redraw!
272 set ts=4
273 redraw!
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200274 let lines = s:screen_lines(line('.'),10)
275 let expect = [
276 \ " 2 ^Iabcd",
277 \ "# opq",
278 \ "# BCD",
279 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100280 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100281 call s:close_windows('set sbr= cpo-=n')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200282endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100283
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200284func Test_breakindent08_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200285 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200286 " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
287 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4 vts=4')
288 " make sure, cache is invalidated!
289 set ts=8
290 redraw!
291 set ts=4
292 redraw!
293 let lines = s:screen_lines(line('.'),10)
294 let expect = [
295 \ " 2 ^Iabcd",
296 \ "# opq",
297 \ "# BCD",
298 \ ]
299 call s:compare_lines(expect, lines)
300 call s:close_windows('set sbr= cpo-=n vts&')
301endfunc
302
303func Test_breakindent08a()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100304 " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100305 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200306 let lines = s:screen_lines(line('.'),10)
307 let expect = [
308 \ " 2 ^Iabcd",
309 \ " # opq",
310 \ " # BCD",
311 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100312 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100313 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200314endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100315
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200316func Test_breakindent08a_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200317 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200318 " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr
319 call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list vts=4')
320 let lines = s:screen_lines(line('.'),10)
321 let expect = [
322 \ " 2 ^Iabcd",
323 \ " # opq",
324 \ " # BCD",
325 \ ]
326 call s:compare_lines(expect, lines)
327 call s:close_windows('set sbr= vts&')
328endfunc
329
330func Test_breakindent09()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100331 " breakindent set and shift by 1, Number and list set sbr=#
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100332 call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200333 let lines = s:screen_lines(line('.'),10)
334 let expect = [
335 \ " 2 ^Iabcd",
336 \ " #op",
337 \ " #AB",
338 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100339 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100340 call s:close_windows('set sbr=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200341endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100342
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200343func Test_breakindent09_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200344 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200345 " breakindent set and shift by 1, Number and list set sbr=#
346 call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list vts=4')
347 let lines = s:screen_lines(line('.'),10)
348 let expect = [
349 \ " 2 ^Iabcd",
350 \ " #op",
351 \ " #AB",
352 \ ]
353 call s:compare_lines(expect, lines)
354 call s:close_windows('set sbr= vts&')
355endfunc
356
357func Test_breakindent10()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100358 " breakindent set, Number set sbr=~
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100359 call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100360 " make sure, cache is invalidated!
361 set ts=8
362 redraw!
363 set ts=4
364 redraw!
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200365 let lines = s:screen_lines(line('.'),10)
366 let expect = [
367 \ " 2 ab",
368 \ "~ mn",
369 \ "~ yz",
370 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100371 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100372 call s:close_windows('set sbr= cpo-=n')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200373endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100374
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200375func Test_breakindent10_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200376 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200377 " breakindent set, Number set sbr=~
378 call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0 vts=4')
379 " make sure, cache is invalidated!
380 set ts=8
381 redraw!
382 set ts=4
383 redraw!
384 let lines = s:screen_lines(line('.'),10)
385 let expect = [
386 \ " 2 ab",
387 \ "~ mn",
388 \ "~ yz",
389 \ ]
390 call s:compare_lines(expect, lines)
391 call s:close_windows('set sbr= cpo-=n vts&')
392endfunc
393
394func Test_breakindent11()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100395 " test strdisplaywidth()
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100396 call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200397 let text = getline(2)
Bram Moolenaarf9f24ce2019-08-31 21:17:39 +0200398 let width = strlen(text[1:]) + indent(2) + strlen(&sbr) * 3 " text wraps 3 times
Bram Moolenaar6c896862016-11-17 19:46:51 +0100399 call assert_equal(width, strdisplaywidth(text))
400 call s:close_windows('set sbr=')
Bram Moolenaar0e05de42020-03-25 22:23:46 +0100401 call assert_equal(4, strdisplaywidth("\t", 4))
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200402endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100403
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200404func Test_breakindent11_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200405 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200406 " test strdisplaywidth()
407 call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4')
408 let text = getline(2)
Bram Moolenaarf9f24ce2019-08-31 21:17:39 +0200409 let width = strlen(text[1:]) + 2->indent() + strlen(&sbr) * 3 " text wraps 3 times
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200410 call assert_equal(width, text->strdisplaywidth())
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200411 call s:close_windows('set sbr= vts&')
412endfunc
413
414func Test_breakindent12()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100415 " test breakindent with long indent
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200416 let s:input = "\t\t\t\t\t{"
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100417 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 +0200418 let lines = s:screen_lines(2,16)
419 let expect = [
420 \ " 2 >--->--->--->",
421 \ " ---{ ",
422 \ "~ ",
423 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100424 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100425 call s:close_windows('set nuw=4 listchars=')
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200426endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100427
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200428func Test_breakindent12_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200429 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200430 " test breakindent with long indent
431 let s:input = "\t\t\t\t\t{"
432 call s:test_windows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>- vts=4')
433 let lines = s:screen_lines(2,16)
434 let expect = [
435 \ " 2 >--->--->--->",
436 \ " ---{ ",
437 \ "~ ",
438 \ ]
439 call s:compare_lines(expect, lines)
440 call s:close_windows('set nuw=4 listchars= vts&')
441endfunc
442
443func Test_breakindent13()
444 let s:input = ""
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100445 call s:test_windows('setl breakindent briopt=min:10 ts=8')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100446 vert resize 20
447 call setline(1, [" a\tb\tc\td\te", " z y x w v"])
448 1
449 norm! fbgj"ayl
450 2
451 norm! fygj"byl
452 call assert_equal('d', @a)
453 call assert_equal('w', @b)
454 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200455endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100456
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200457func Test_breakindent13_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200458 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200459 let s:input = ""
460 call s:test_windows('setl breakindent briopt=min:10 ts=8 vts=8')
461 vert resize 20
462 call setline(1, [" a\tb\tc\td\te", " z y x w v"])
463 1
464 norm! fbgj"ayl
465 2
466 norm! fygj"byl
467 call assert_equal('d', @a)
468 call assert_equal('w', @b)
469 call s:close_windows('set vts&')
470endfunc
471
472func Test_breakindent14()
473 let s:input = ""
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100474 call s:test_windows('setl breakindent briopt= ts=8')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100475 vert resize 30
476 norm! 3a1234567890
477 norm! a abcde
478 exec "norm! 0\<C-V>tex"
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200479 let lines = s:screen_lines(line('.'),8)
480 let expect = [
481 \ "e ",
482 \ "~ ",
483 \ "~ ",
484 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100485 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100486 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200487endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100488
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200489func Test_breakindent14_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200490 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200491 let s:input = ""
492 call s:test_windows('setl breakindent briopt= ts=8 vts=8')
493 vert resize 30
494 norm! 3a1234567890
495 norm! a abcde
496 exec "norm! 0\<C-V>tex"
497 let lines = s:screen_lines(line('.'),8)
498 let expect = [
499 \ "e ",
500 \ "~ ",
501 \ "~ ",
502 \ ]
503 call s:compare_lines(expect, lines)
504 call s:close_windows('set vts&')
505endfunc
506
507func Test_breakindent15()
508 let s:input = ""
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100509 call s:test_windows('setl breakindent briopt= ts=8 sw=8')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100510 vert resize 30
511 norm! 4a1234567890
512 exe "normal! >>\<C-V>3f0x"
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200513 let lines = s:screen_lines(line('.'),20)
514 let expect = [
515 \ " 1234567890 ",
516 \ "~ ",
517 \ "~ ",
518 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100519 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100520 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200521endfunc
Bram Moolenaar6c896862016-11-17 19:46:51 +0100522
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200523func Test_breakindent15_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200524 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200525 let s:input = ""
526 call s:test_windows('setl breakindent briopt= ts=8 sw=8 vts=8')
527 vert resize 30
528 norm! 4a1234567890
529 exe "normal! >>\<C-V>3f0x"
530 let lines = s:screen_lines(line('.'),20)
531 let expect = [
532 \ " 1234567890 ",
533 \ "~ ",
534 \ "~ ",
535 \ ]
536 call s:compare_lines(expect, lines)
537 call s:close_windows('set vts&')
538endfunc
539
540func Test_breakindent16()
Bram Moolenaar6c896862016-11-17 19:46:51 +0100541 " Check that overlong lines are indented correctly.
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200542 let s:input = ""
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100543 call s:test_windows('setl breakindent briopt=min:0 ts=4')
Bram Moolenaar6c896862016-11-17 19:46:51 +0100544 call setline(1, "\t".repeat("1234567890", 10))
545 resize 6
546 norm! 1gg$
547 redraw!
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200548 let lines = s:screen_lines(1,10)
549 let expect = [
550 \ " 789012",
551 \ " 345678",
552 \ " 901234",
553 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100554 call s:compare_lines(expect, lines)
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200555 let lines = s:screen_lines(4,10)
556 let expect = [
557 \ " 567890",
558 \ " 123456",
559 \ " 7890 ",
560 \ ]
Bram Moolenaar544d3bc2017-02-05 21:14:50 +0100561 call s:compare_lines(expect, lines)
Bram Moolenaar6c896862016-11-17 19:46:51 +0100562 call s:close_windows()
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200563endfunc
564
565func Test_breakindent16_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200566 CheckFeature vartabs
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200567 " Check that overlong lines are indented correctly.
568 let s:input = ""
569 call s:test_windows('setl breakindent briopt=min:0 ts=4 vts=4')
570 call setline(1, "\t".repeat("1234567890", 10))
571 resize 6
572 norm! 1gg$
573 redraw!
574 let lines = s:screen_lines(1,10)
575 let expect = [
576 \ " 789012",
577 \ " 345678",
578 \ " 901234",
579 \ ]
580 call s:compare_lines(expect, lines)
581 let lines = s:screen_lines(4,10)
582 let expect = [
583 \ " 567890",
584 \ " 123456",
585 \ " 7890 ",
586 \ ]
587 call s:compare_lines(expect, lines)
588 call s:close_windows('set vts&')
589endfunc
Bram Moolenaar2f7b7b12019-11-03 15:46:48 +0100590
591func Test_breakindent17_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200592 CheckFeature vartabs
Bram Moolenaar2f7b7b12019-11-03 15:46:48 +0100593 let s:input = ""
594 call s:test_windows('setl breakindent list listchars=tab:<-> showbreak=+++')
595 call setline(1, "\t" . repeat('a', 63))
596 vert resize 30
597 norm! 1gg$
598 redraw!
599 let lines = s:screen_lines(1, 30)
600 let expect = [
601 \ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa",
602 \ " +++aaaaaaaaaaaaaaaaaaaaaaa",
603 \ " +++aaaaaaaaaaaaaa ",
604 \ ]
605 call s:compare_lines(expect, lines)
606 call s:close_windows('set breakindent& list& listchars& showbreak&')
607endfunc
608
609func Test_breakindent18_vartabs()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200610 CheckFeature vartabs
Bram Moolenaar2f7b7b12019-11-03 15:46:48 +0100611 let s:input = ""
612 call s:test_windows('setl breakindent list listchars=tab:<->')
613 call setline(1, "\t" . repeat('a', 63))
614 vert resize 30
615 norm! 1gg$
616 redraw!
617 let lines = s:screen_lines(1, 30)
618 let expect = [
619 \ "<-->aaaaaaaaaaaaaaaaaaaaaaaaaa",
620 \ " aaaaaaaaaaaaaaaaaaaaaaaaaa",
621 \ " aaaaaaaaaaa ",
622 \ ]
623 call s:compare_lines(expect, lines)
624 call s:close_windows('set breakindent& list& listchars&')
625endfunc
626
Bram Moolenaardfede9a2020-01-23 19:59:22 +0100627func Test_breakindent19_sbr_nextpage()
628 let s:input = ""
629 call s:test_windows('setl breakindent briopt=shift:2,sbr,min:18 sbr=>')
630 call setline(1, repeat('a', 200))
631 norm! 1gg
632 redraw!
633 let lines = s:screen_lines(1, 20)
634 let expect = [
635 \ "aaaaaaaaaaaaaaaaaaaa",
636 \ "> aaaaaaaaaaaaaaaaaa",
637 \ "> aaaaaaaaaaaaaaaaaa",
638 \ ]
639 call s:compare_lines(expect, lines)
640 " Scroll down one screen line
641 setl scrolloff=5
Bram Moolenaar52029292021-02-10 21:20:30 +0100642 norm! 5gj
Bram Moolenaardfede9a2020-01-23 19:59:22 +0100643 let lines = s:screen_lines(1, 20)
644 let expect = [
Bram Moolenaar52029292021-02-10 21:20:30 +0100645 \ "aaaaaaaaaaaaaaaaaaaa",
Bram Moolenaardfede9a2020-01-23 19:59:22 +0100646 \ "> aaaaaaaaaaaaaaaaaa",
647 \ "> aaaaaaaaaaaaaaaaaa",
648 \ ]
649 call s:compare_lines(expect, lines)
Bram Moolenaar52029292021-02-10 21:20:30 +0100650 redraw!
651 " moving the cursor doesn't change the text offset
652 norm! l
653 redraw!
654 let lines = s:screen_lines(1, 20)
655 call s:compare_lines(expect, lines)
Bram Moolenaar1aa76b82020-02-23 15:17:27 +0100656
657 setl breakindent briopt=min:18 sbr=>
658 norm! 5gj
659 let lines = s:screen_lines(1, 20)
660 let expect = [
661 \ ">aaaaaaaaaaaaaaaaaaa",
662 \ ">aaaaaaaaaaaaaaaaaaa",
663 \ ">aaaaaaaaaaaaaaaaaaa",
664 \ ]
665 call s:compare_lines(expect, lines)
Bram Moolenaardfede9a2020-01-23 19:59:22 +0100666 call s:close_windows('set breakindent& briopt& sbr&')
667endfunc
Bram Moolenaar0e05de42020-03-25 22:23:46 +0100668
Bram Moolenaare882f7a2020-05-16 14:07:39 +0200669func Test_breakindent20_cpo_n_nextpage()
670 let s:input = ""
671 call s:test_windows('setl breakindent briopt=min:14 cpo+=n number')
672 call setline(1, repeat('a', 200))
673 norm! 1gg
674 redraw!
675 let lines = s:screen_lines(1, 20)
676 let expect = [
677 \ " 1 aaaaaaaaaaaaaaaa",
678 \ " aaaaaaaaaaaaaaaa",
679 \ " aaaaaaaaaaaaaaaa",
680 \ ]
681 call s:compare_lines(expect, lines)
682 " Scroll down one screen line
683 setl scrolloff=5
684 norm! 5gj
685 redraw!
686 let lines = s:screen_lines(1, 20)
687 let expect = [
688 \ "--1 aaaaaaaaaaaaaaaa",
689 \ " aaaaaaaaaaaaaaaa",
690 \ " aaaaaaaaaaaaaaaa",
691 \ ]
692 call s:compare_lines(expect, lines)
693
694 setl briopt+=shift:2
695 norm! 1gg
696 let lines = s:screen_lines(1, 20)
697 let expect = [
698 \ " 1 aaaaaaaaaaaaaaaa",
699 \ " aaaaaaaaaaaaaa",
700 \ " aaaaaaaaaaaaaa",
701 \ ]
702 call s:compare_lines(expect, lines)
703 " Scroll down one screen line
704 norm! 5gj
705 let lines = s:screen_lines(1, 20)
706 let expect = [
707 \ "--1 aaaaaaaaaaaaaa",
708 \ " aaaaaaaaaaaaaa",
709 \ " aaaaaaaaaaaaaa",
710 \ ]
711 call s:compare_lines(expect, lines)
712
713 call s:close_windows('set breakindent& briopt& cpo& number&')
714endfunc
715
Christian Brabandt4a0b85a2021-07-14 20:00:27 +0200716func Test_breakindent20_list()
717 call s:test_windows('setl breakindent breakindentopt= linebreak')
718 " default:
719 call setline(1, [' 1. Congress shall make no law',
720 \ ' 2.) Congress shall make no law',
721 \ ' 3.] Congress shall make no law'])
722 norm! 1gg
723 redraw!
724 let lines = s:screen_lines2(1, 6, 20)
725 let expect = [
726 \ " 1. Congress ",
727 \ "shall make no law ",
728 \ " 2.) Congress ",
729 \ "shall make no law ",
730 \ " 3.] Congress ",
731 \ "shall make no law ",
732 \ ]
733 call s:compare_lines(expect, lines)
Dominique Pelle81b573d2022-03-22 21:14:55 +0000734 " set minimum indent
Christian Brabandt4a0b85a2021-07-14 20:00:27 +0200735 setl briopt=min:5
736 redraw!
737 let lines = s:screen_lines2(1, 6, 20)
738 let expect = [
739 \ " 1. Congress ",
740 \ " shall make no law ",
741 \ " 2.) Congress ",
742 \ " shall make no law ",
743 \ " 3.] Congress ",
744 \ " shall make no law ",
745 \ ]
746 call s:compare_lines(expect, lines)
747 " set additional handing indent
748 setl briopt+=list:4
749 redraw!
750 let expect = [
751 \ " 1. Congress ",
752 \ " shall make no ",
753 \ " law ",
754 \ " 2.) Congress ",
755 \ " shall make no ",
756 \ " law ",
757 \ " 3.] Congress ",
758 \ " shall make no ",
759 \ " law ",
760 \ ]
761 let lines = s:screen_lines2(1, 9, 20)
762 call s:compare_lines(expect, lines)
Maxim Kimf674b352021-07-22 11:46:59 +0200763
Christian Brabandt4a0b85a2021-07-14 20:00:27 +0200764 " reset linebreak option
765 " Note: it indents by one additional
766 " space, because of the leading space.
767 setl linebreak&vim list listchars=eol:$,space:_
768 redraw!
769 let expect = [
770 \ "__1.__Congress_shall",
771 \ " _make_no_law$ ",
772 \ "__2.)_Congress_shall",
773 \ " _make_no_law$ ",
774 \ "__3.]_Congress_shall",
775 \ " _make_no_law$ ",
776 \ ]
777 let lines = s:screen_lines2(1, 6, 20)
778 call s:compare_lines(expect, lines)
779
Maxim Kimf674b352021-07-22 11:46:59 +0200780 " check formatlistpat indent
781 setl briopt=min:5,list:-1
782 setl linebreak list&vim listchars&vim
783 let &l:flp = '^\s*\d\+\.\?[\]:)}\t ]\s*'
784 redraw!
785 let expect = [
786 \ " 1. Congress ",
787 \ " shall make no ",
788 \ " law ",
789 \ " 2.) Congress ",
790 \ " shall make no ",
791 \ " law ",
792 \ " 3.] Congress ",
793 \ " shall make no ",
794 \ " law ",
795 \ ]
796 let lines = s:screen_lines2(1, 9, 20)
797 call s:compare_lines(expect, lines)
798 " check formatlistpat indent with different list levels
799 let &l:flp = '^\s*\*\+\s\+'
800 redraw!
801 %delete _
802 call setline(1, ['* Congress shall make no law',
803 \ '*** Congress shall make no law',
804 \ '**** Congress shall make no law'])
805 norm! 1gg
806 let expect = [
807 \ "* Congress shall ",
808 \ " make no law ",
809 \ "*** Congress shall ",
810 \ " make no law ",
811 \ "**** Congress shall ",
812 \ " make no law ",
813 \ ]
814 let lines = s:screen_lines2(1, 6, 20)
815 call s:compare_lines(expect, lines)
816
817 " check formatlistpat indent with different list level
818 " showbreak and sbr
819 setl briopt=min:5,sbr,list:-1,shift:2
820 setl showbreak=>
821 redraw!
822 let expect = [
823 \ "* Congress shall ",
824 \ "> make no law ",
825 \ "*** Congress shall ",
826 \ "> make no law ",
827 \ "**** Congress shall ",
828 \ "> make no law ",
829 \ ]
830 let lines = s:screen_lines2(1, 6, 20)
831 call s:compare_lines(expect, lines)
832 call s:close_windows('set breakindent& briopt& linebreak& list& listchars& showbreak&')
Christian Brabandt4a0b85a2021-07-14 20:00:27 +0200833endfunc
834
Yegappan Lakshmanan03d25792021-09-02 20:05:26 +0200835" The following used to crash Vim. This is fixed by 8.2.3391.
836" This is a regression introduced by 8.2.2903.
837func Test_window_resize_with_linebreak()
838 new
839 53vnew
840 set linebreak
841 set showbreak=>>
842 set breakindent
843 set breakindentopt=shift:4
844 call setline(1, "\naaaaaaaaa\n\na\naaaaa\n¯aaaaaaaaaa\naaaaaaaaaaaa\naaa\n\"a:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - aaaaaaaa\"\naaaaaaaa\n\"a")
845 redraw!
846 call assert_equal([" >>aa^@\"a: "], ScreenLines(2, 14))
847 vertical resize 52
848 redraw!
849 call assert_equal([" >>aaa^@\"a:"], ScreenLines(2, 14))
850 %bw!
851endfunc
852
Bram Moolenaar21efafe2022-03-03 20:04:03 +0000853func Test_cursor_position_with_showbreak()
854 CheckScreendump
855
856 let lines =<< trim END
857 vim9script
858 &signcolumn = 'yes'
859 &showbreak = '+ '
860 var leftcol: number = win_getid()->getwininfo()->get(0, {})->get('textoff')
861 repeat('x', &columns - leftcol - 1)->setline(1)
862 'second line'->setline(2)
863 END
864 call writefile(lines, 'XscriptShowbreak')
865 let buf = RunVimInTerminal('-S XscriptShowbreak', #{rows: 6})
866
867 call term_sendkeys(buf, "AX")
868 call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak', {})
869
870 call StopVimInTerminal(buf)
871 call delete('XscriptShowbreak')
872endfunc
873
Christian Brabandtc53b4672022-01-15 10:01:05 +0000874func Test_no_spurious_match()
875 let s:input = printf('- y %s y %s', repeat('x', 50), repeat('x', 50))
876 call s:test_windows('setl breakindent breakindentopt=list:-1 formatlistpat=^- hls')
877 let @/ = '\%>3v[y]'
878 redraw!
879 call searchcount().total->assert_equal(1)
880 " cleanup
881 set hls&vim
882 let s:input = "\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP"
883 bwipeout!
884endfunc
885
886func Test_no_extra_indent()
887 call s:test_windows('setl breakindent breakindentopt=list:-1,min:10')
888 %d
889 let &l:formatlistpat='^\s*\d\+\.\s\+'
890 let text = 'word '
891 let len = text->strcharlen()
892 let line1 = text->repeat((winwidth(0) / len) * 2)
893 let line2 = repeat(' ', 2) .. '1. ' .. line1
894 call setline(1, [line2])
895 redraw!
896 " 1) matches formatlist pattern, so indent
897 let expect = [
898 \ " 1. word word word ",
899 \ " word word word ",
900 \ " word word ",
901 \ "~ ",
902 \ ]
903 let lines = s:screen_lines2(1, 4, 20)
904 call s:compare_lines(expect, lines)
905 " 2) change formatlist pattern
906 " -> indent adjusted
907 let &l:formatlistpat='^\s*\d\+\.'
908 let expect = [
909 \ " 1. word word word ",
910 \ " word word word ",
911 \ " word word ",
912 \ "~ ",
913 \ ]
914 let lines = s:screen_lines2(1, 4, 20)
Bram Moolenaar04b871d2022-01-15 18:31:43 +0000915 " 3) no local formatlist pattern,
916 " so use global one -> indent
917 let g_flp = &g:flp
918 let &g:formatlistpat='^\s*\d\+\.\s\+'
919 let &l:formatlistpat=''
920 let expect = [
921 \ " 1. word word word ",
922 \ " word word word ",
923 \ " word word ",
924 \ "~ ",
925 \ ]
926 let lines = s:screen_lines2(1, 4, 20)
927 call s:compare_lines(expect, lines)
928 let &g:flp = g_flp
929 let &l:formatlistpat='^\s*\d\+\.'
930 " 4) add something in front, no additional indent
Christian Brabandtc53b4672022-01-15 10:01:05 +0000931 norm! gg0
932 exe ":norm! 5iword \<esc>"
933 redraw!
934 let expect = [
935 \ "word word word word ",
936 \ "word 1. word word ",
937 \ "word word word word ",
938 \ "word word ",
939 \ "~ ",
940 \ ]
941 let lines = s:screen_lines2(1, 5, 20)
942 call s:compare_lines(expect, lines)
943 bwipeout!
944endfunc
945
Bram Moolenaar0e05de42020-03-25 22:23:46 +0100946" vim: shiftwidth=2 sts=2 expandtab