blob: a255457b2e6f3df6eaf8d2f705473523942cc02c [file] [log] [blame]
Bram Moolenaar597a4222014-06-25 14:39:50 +02001Test for breakindent
2
3STARTTEST
4:so small.vim
5:if !exists("+breakindent") | e! test.ok | w! test.out | qa! | endif
6:10new|:vsp|:vert resize 20
7:put =\"\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP\"
8:set ts=4 sw=4 sts=4 breakindent
Bram Moolenaarbaf03442014-11-27 14:09:13 +01009:fu! ScreenChar(line, width)
Bram Moolenaar597a4222014-06-25 14:39:50 +020010: let c=''
11: for i in range(1,a:width)
Bram Moolenaarbaf03442014-11-27 14:09:13 +010012: let c.=nr2char(screenchar(a:line, i))
Bram Moolenaar597a4222014-06-25 14:39:50 +020013: endfor
14: let c.="\n"
15: for i in range(1,a:width)
Bram Moolenaarbaf03442014-11-27 14:09:13 +010016: let c.=nr2char(screenchar(a:line+1, i))
Bram Moolenaar597a4222014-06-25 14:39:50 +020017: endfor
18: let c.="\n"
19: for i in range(1,a:width)
Bram Moolenaarbaf03442014-11-27 14:09:13 +010020: let c.=nr2char(screenchar(a:line+2, i))
Bram Moolenaar597a4222014-06-25 14:39:50 +020021: endfor
22: return c
23:endfu
24:fu DoRecordScreen()
25: wincmd l
26: $put =printf(\"\n%s\", g:test)
27: $put =g:line1
28: wincmd p
29:endfu
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020030:set briopt=min:0
Bram Moolenaar597a4222014-06-25 14:39:50 +020031:let g:test="Test 1: Simple breakindent"
Bram Moolenaarbaf03442014-11-27 14:09:13 +010032:let line1=ScreenChar(line('.'),8)
Bram Moolenaar597a4222014-06-25 14:39:50 +020033:call DoRecordScreen()
34:let g:test="Test 2: Simple breakindent + sbr=>>"
35:set sbr=>>
Bram Moolenaarbaf03442014-11-27 14:09:13 +010036:let line1=ScreenChar(line('.'),8)
Bram Moolenaar597a4222014-06-25 14:39:50 +020037:call DoRecordScreen()
38:let g:test ="Test 3: Simple breakindent + briopt:sbr"
39:set briopt=sbr,min:0 sbr=++
Bram Moolenaarbaf03442014-11-27 14:09:13 +010040:let line1=ScreenChar(line('.'),8)
Bram Moolenaar597a4222014-06-25 14:39:50 +020041:call DoRecordScreen()
42:let g:test ="Test 4: Simple breakindent + min width: 18"
43:set sbr= briopt=min:18
Bram Moolenaarbaf03442014-11-27 14:09:13 +010044:let line1=ScreenChar(line('.'),8)
Bram Moolenaar597a4222014-06-25 14:39:50 +020045:call DoRecordScreen()
46:let g:test =" Test 5: Simple breakindent + shift by 2"
47:set briopt=shift:2,min:0
Bram Moolenaarbaf03442014-11-27 14:09:13 +010048:let line1=ScreenChar(line('.'),8)
Bram Moolenaar597a4222014-06-25 14:39:50 +020049:call DoRecordScreen()
50:let g:test=" Test 6: Simple breakindent + shift by -1"
51:set briopt=shift:-1,min:0
Bram Moolenaarbaf03442014-11-27 14:09:13 +010052:let line1=ScreenChar(line('.'),8)
Bram Moolenaar597a4222014-06-25 14:39:50 +020053:call DoRecordScreen()
54:let g:test=" Test 7: breakindent + shift by +1 + nu + sbr=? briopt:sbr"
55:set briopt=shift:1,sbr,min:0 nu sbr=? nuw=4
Bram Moolenaarbaf03442014-11-27 14:09:13 +010056:let line1=ScreenChar(line('.'),10)
Bram Moolenaar597a4222014-06-25 14:39:50 +020057:call DoRecordScreen()
58:let g:test=" Test 8: breakindent + shift:1 + nu + sbr=# list briopt:sbr"
59:set briopt=shift:1,sbr,min:0 nu sbr=# list
Bram Moolenaarbaf03442014-11-27 14:09:13 +010060:let line1=ScreenChar(line('.'),10)
Bram Moolenaar597a4222014-06-25 14:39:50 +020061:call DoRecordScreen()
62:let g:test=" Test 9: breakindent + shift by +1 + 'nu' + sbr=# list"
63:set briopt-=sbr
Bram Moolenaarbaf03442014-11-27 14:09:13 +010064:let line1=ScreenChar(line('.'),10)
Bram Moolenaar597a4222014-06-25 14:39:50 +020065:call DoRecordScreen()
66:let g:test=" Test 10: breakindent + shift by +1 + 'nu' + sbr=~ cpo+=n"
67:set cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0
Bram Moolenaarbaf03442014-11-27 14:09:13 +010068:let line1=ScreenChar(line('.'),10)
Bram Moolenaar597a4222014-06-25 14:39:50 +020069:call DoRecordScreen()
70:wincmd p
71:let g:test="\n Test 11: strdisplaywidth when breakindent is on"
72:set cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4
73:let text=getline(2) "skip leading tab when calculating text width
74:let width = strlen(text[1:])+indent(2)*4+strlen(&sbr)*3 " text wraps 3 times
75:$put =g:test
76:$put =printf(\"strdisplaywidth: %d == calculated: %d\", strdisplaywidth(text), width)
Bram Moolenaarbaf03442014-11-27 14:09:13 +010077:let g:str="\t\t\t\t\t{"
78:let g:test=" Test 12: breakindent + long indent"
79:wincmd p
80:set all& breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4
81:$put =g:str
82zt:let line1=ScreenChar(1,10)
83:wincmd p
84:call DoRecordScreen()
Bram Moolenaar95765082014-08-24 21:19:25 +020085:"
86:" Test, that the string " a\tb\tc\td\te" is correctly
87:" displayed in a 20 column wide window (see bug report
88:" https://groups.google.com/d/msg/vim_dev/ZOdg2mc9c9Y/TT8EhFjEy0IJ
89:only
90:vert 20new
91:set all& nocp breakindent briopt=min:10
92:call setline(1, [" a\tb\tc\td\te", " z y x w v"])
93:/^\s*a
94fbgjyl:let line1 = @0
95:?^\s*z
96fygjyl:let line2 = @0
97:quit!
Bram Moolenaarbaf03442014-11-27 14:09:13 +010098:$put ='Test 13: breakindent with wrapping Tab'
Bram Moolenaar95765082014-08-24 21:19:25 +020099:$put =line1
100:$put =line2
101:"
Bram Moolenaar597a4222014-06-25 14:39:50 +0200102:%w! test.out
103:qa!
104ENDTEST
105dummy text