Bram Moolenaar | 597a422 | 2014-06-25 14:39:50 +0200 | [diff] [blame] | 1 | Test for breakindent |
| 2 | |
| 3 | STARTTEST |
| 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 |
Bram Moolenaar | 285ed7e | 2014-08-24 21:39:49 +0200 | [diff] [blame] | 30 | :set briopt=min:0 |
Bram Moolenaar | 597a422 | 2014-06-25 14:39:50 +0200 | [diff] [blame] | 31 | :let g:test="Test 1: Simple breakindent" |
| 32 | :let line1=ScreenChar(8) |
| 33 | :call DoRecordScreen() |
| 34 | :let g:test="Test 2: Simple breakindent + sbr=>>" |
| 35 | :set sbr=>> |
| 36 | :let line1=ScreenChar(8) |
| 37 | :call DoRecordScreen() |
| 38 | :let g:test ="Test 3: Simple breakindent + briopt:sbr" |
| 39 | :set briopt=sbr,min:0 sbr=++ |
| 40 | :let line1=ScreenChar(8) |
| 41 | :call DoRecordScreen() |
| 42 | :let g:test ="Test 4: Simple breakindent + min width: 18" |
| 43 | :set sbr= briopt=min:18 |
| 44 | :let line1=ScreenChar(8) |
| 45 | :call DoRecordScreen() |
| 46 | :let g:test =" Test 5: Simple breakindent + shift by 2" |
| 47 | :set briopt=shift:2,min:0 |
| 48 | :let line1=ScreenChar(8) |
| 49 | :call DoRecordScreen() |
| 50 | :let g:test=" Test 6: Simple breakindent + shift by -1" |
| 51 | :set briopt=shift:-1,min:0 |
| 52 | :let line1=ScreenChar(8) |
| 53 | :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 |
| 56 | :let line1=ScreenChar(10) |
| 57 | :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 |
| 60 | :let line1=ScreenChar(10) |
| 61 | :call DoRecordScreen() |
| 62 | :let g:test=" Test 9: breakindent + shift by +1 + 'nu' + sbr=# list" |
| 63 | :set briopt-=sbr |
| 64 | :let line1=ScreenChar(10) |
| 65 | :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 |
| 68 | :let line1=ScreenChar(10) |
| 69 | :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 Moolenaar | 9576508 | 2014-08-24 21:19:25 +0200 | [diff] [blame] | 77 | :" |
| 78 | :" Test, that the string " a\tb\tc\td\te" is correctly |
| 79 | :" displayed in a 20 column wide window (see bug report |
| 80 | :" https://groups.google.com/d/msg/vim_dev/ZOdg2mc9c9Y/TT8EhFjEy0IJ |
| 81 | :only |
| 82 | :vert 20new |
| 83 | :set all& nocp breakindent briopt=min:10 |
| 84 | :call setline(1, [" a\tb\tc\td\te", " z y x w v"]) |
| 85 | :/^\s*a |
| 86 | fbgjyl:let line1 = @0 |
| 87 | :?^\s*z |
| 88 | fygjyl:let line2 = @0 |
| 89 | :quit! |
| 90 | :$put ='Test 12: breakindent with wrapping Tab' |
| 91 | :$put =line1 |
| 92 | :$put =line2 |
| 93 | :" |
Bram Moolenaar | 597a422 | 2014-06-25 14:39:50 +0200 | [diff] [blame] | 94 | :%w! test.out |
| 95 | :qa! |
| 96 | ENDTEST |
| 97 | dummy text |