blob: 79e25f79de09fdab6e74281fc09f9bb1e31bd165 [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
9:fu! ScreenChar(width)
10: let c=''
11: for i in range(1,a:width)
12: let c.=nr2char(screenchar(line('.'), i))
13: endfor
14: let c.="\n"
15: for i in range(1,a:width)
16: let c.=nr2char(screenchar(line('.')+1, i))
17: endfor
18: let c.="\n"
19: for i in range(1,a:width)
20: let c.=nr2char(screenchar(line('.')+2, i))
21: 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
30:let g:test="Test 1: Simple breakindent"
31:let line1=ScreenChar(8)
32:call DoRecordScreen()
33:let g:test="Test 2: Simple breakindent + sbr=>>"
34:set sbr=>>
35:let line1=ScreenChar(8)
36:call DoRecordScreen()
37:let g:test ="Test 3: Simple breakindent + briopt:sbr"
38:set briopt=sbr,min:0 sbr=++
39:let line1=ScreenChar(8)
40:call DoRecordScreen()
41:let g:test ="Test 4: Simple breakindent + min width: 18"
42:set sbr= briopt=min:18
43:let line1=ScreenChar(8)
44:call DoRecordScreen()
45:let g:test =" Test 5: Simple breakindent + shift by 2"
46:set briopt=shift:2,min:0
47:let line1=ScreenChar(8)
48:call DoRecordScreen()
49:let g:test=" Test 6: Simple breakindent + shift by -1"
50:set briopt=shift:-1,min:0
51:let line1=ScreenChar(8)
52:call DoRecordScreen()
53:let g:test=" Test 7: breakindent + shift by +1 + nu + sbr=? briopt:sbr"
54:set briopt=shift:1,sbr,min:0 nu sbr=? nuw=4
55:let line1=ScreenChar(10)
56:call DoRecordScreen()
57:let g:test=" Test 8: breakindent + shift:1 + nu + sbr=# list briopt:sbr"
58:set briopt=shift:1,sbr,min:0 nu sbr=# list
59:let line1=ScreenChar(10)
60:call DoRecordScreen()
61:let g:test=" Test 9: breakindent + shift by +1 + 'nu' + sbr=# list"
62:set briopt-=sbr
63:let line1=ScreenChar(10)
64:call DoRecordScreen()
65:let g:test=" Test 10: breakindent + shift by +1 + 'nu' + sbr=~ cpo+=n"
66:set cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0
67:let line1=ScreenChar(10)
68:call DoRecordScreen()
69:wincmd p
70:let g:test="\n Test 11: strdisplaywidth when breakindent is on"
71:set cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4
72:let text=getline(2) "skip leading tab when calculating text width
73:let width = strlen(text[1:])+indent(2)*4+strlen(&sbr)*3 " text wraps 3 times
74:$put =g:test
75:$put =printf(\"strdisplaywidth: %d == calculated: %d\", strdisplaywidth(text), width)
Bram Moolenaar95765082014-08-24 21:19:25 +020076:"
77:" Test, that the string " a\tb\tc\td\te" is correctly
78:" displayed in a 20 column wide window (see bug report
79:" https://groups.google.com/d/msg/vim_dev/ZOdg2mc9c9Y/TT8EhFjEy0IJ
80:only
81:vert 20new
82:set all& nocp breakindent briopt=min:10
83:call setline(1, [" a\tb\tc\td\te", " z y x w v"])
84:/^\s*a
85fbgjyl:let line1 = @0
86:?^\s*z
87fygjyl:let line2 = @0
88:quit!
89:$put ='Test 12: breakindent with wrapping Tab'
90:$put =line1
91:$put =line2
92:"
Bram Moolenaar597a4222014-06-25 14:39:50 +020093:%w! test.out
94:qa!
95ENDTEST
96dummy text