2015-06-10 17:01:11 -07:00
|
|
|
-- Test for breakindent
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2016-05-19 21:30:01 -07:00
|
|
|
local feed, insert = helpers.feed, helpers.insert
|
2017-04-08 14:12:26 -07:00
|
|
|
local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
|
2015-06-10 17:01:11 -07:00
|
|
|
|
|
|
|
describe('breakindent', function()
|
|
|
|
setup(clear)
|
|
|
|
|
2017-09-24 11:42:48 -07:00
|
|
|
-- luacheck: ignore 621 (Indentation)
|
|
|
|
-- luacheck: ignore 613 (Trailing whitespace in a string)
|
|
|
|
-- luacheck: ignore 611 (Line contains only whitespaces)
|
2015-06-10 17:01:11 -07:00
|
|
|
it('is working', function()
|
|
|
|
insert('dummy text')
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('set wildchar=^E')
|
|
|
|
feed_command('10new')
|
|
|
|
feed_command('vsp')
|
|
|
|
feed_command('vert resize 20')
|
|
|
|
feed_command([[put =\"\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP\"]])
|
|
|
|
feed_command('set ts=4 sw=4 sts=4 breakindent')
|
|
|
|
feed_command('fu! ScreenChar(line, width)')
|
|
|
|
feed_command(' let c=""')
|
|
|
|
feed_command(' for i in range(1,a:width)')
|
|
|
|
feed_command(' let c.=nr2char(screenchar(a:line, i))')
|
|
|
|
feed_command(' endfor')
|
|
|
|
feed_command([[ let c.="\n"]])
|
|
|
|
feed_command(' for i in range(1,a:width)')
|
|
|
|
feed_command(' let c.=nr2char(screenchar(a:line+1, i))')
|
|
|
|
feed_command(' endfor')
|
|
|
|
feed_command([[ let c.="\n"]])
|
|
|
|
feed_command(' for i in range(1,a:width)')
|
|
|
|
feed_command(' let c.=nr2char(screenchar(a:line+2, i))')
|
|
|
|
feed_command(' endfor')
|
|
|
|
feed_command(' return c')
|
|
|
|
feed_command('endfu')
|
|
|
|
feed_command('fu DoRecordScreen()')
|
|
|
|
feed_command(' wincmd l')
|
|
|
|
feed_command([[ $put =printf(\"\n%s\", g:test)]])
|
|
|
|
feed_command(' $put =g:line1')
|
|
|
|
feed_command(' wincmd p')
|
|
|
|
feed_command('endfu')
|
|
|
|
feed_command('set briopt=min:0')
|
|
|
|
feed_command('let g:test="Test 1: Simple breakindent"')
|
|
|
|
feed_command('let line1=ScreenChar(line("."),8)')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
feed_command('let g:test="Test 2: Simple breakindent + sbr=>>"')
|
|
|
|
feed_command('set sbr=>>')
|
|
|
|
feed_command('let line1=ScreenChar(line("."),8)')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
feed_command('let g:test ="Test 3: Simple breakindent + briopt:sbr"')
|
|
|
|
feed_command('set briopt=sbr,min:0 sbr=++')
|
|
|
|
feed_command('let line1=ScreenChar(line("."),8)')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
feed_command('let g:test ="Test 4: Simple breakindent + min width: 18"')
|
|
|
|
feed_command('set sbr= briopt=min:18')
|
|
|
|
feed_command('let line1=ScreenChar(line("."),8)')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
feed_command('let g:test =" Test 5: Simple breakindent + shift by 2"')
|
|
|
|
feed_command('set briopt=shift:2,min:0')
|
|
|
|
feed_command('let line1=ScreenChar(line("."),8)')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
feed_command('let g:test=" Test 6: Simple breakindent + shift by -1"')
|
|
|
|
feed_command('set briopt=shift:-1,min:0')
|
|
|
|
feed_command('let line1=ScreenChar(line("."),8)')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
feed_command('let g:test=" Test 7: breakindent + shift by +1 + nu + sbr=? briopt:sbr"')
|
|
|
|
feed_command('set briopt=shift:1,sbr,min:0 nu sbr=? nuw=4')
|
|
|
|
feed_command('let line1=ScreenChar(line("."),10)')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
feed_command('let g:test=" Test 8: breakindent + shift:1 + nu + sbr=# list briopt:sbr"')
|
|
|
|
feed_command('set briopt=shift:1,sbr,min:0 nu sbr=# list lcs&vi')
|
|
|
|
feed_command('let line1=ScreenChar(line("."),10)')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
feed_command([[let g:test=" Test 9: breakindent + shift by +1 + 'nu' + sbr=# list"]])
|
|
|
|
feed_command('set briopt-=sbr')
|
|
|
|
feed_command('let line1=ScreenChar(line("."),10)')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
feed_command([[let g:test=" Test 10: breakindent + shift by +1 + 'nu' + sbr=~ cpo+=n"]])
|
|
|
|
feed_command('set cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0')
|
|
|
|
feed_command('let line1=ScreenChar(line("."),10)')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
feed_command('wincmd p')
|
|
|
|
feed_command([[let g:test="\n Test 11: strdisplaywidth when breakindent is on"]])
|
|
|
|
feed_command('set cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4')
|
2015-06-10 17:01:11 -07:00
|
|
|
-- Skip leading tab when calculating text width.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let text=getline(2)')
|
2015-06-10 17:01:11 -07:00
|
|
|
-- Text wraps 3 times.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let width = strlen(text[1:])+indent(2)*4+strlen(&sbr)*3')
|
|
|
|
feed_command('$put =g:test')
|
|
|
|
feed_command([[$put =printf(\"strdisplaywidth: %d == calculated: %d\", strdisplaywidth(text), width)]])
|
|
|
|
feed_command([[let g:str="\t\t\t\t\t{"]])
|
|
|
|
feed_command('let g:test=" Test 12: breakindent + long indent"')
|
|
|
|
feed_command('wincmd p')
|
|
|
|
feed_command('set all& breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4')
|
|
|
|
feed_command('$put =g:str')
|
2015-06-10 17:01:11 -07:00
|
|
|
feed('zt')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let line1=ScreenChar(1,10)')
|
|
|
|
feed_command('wincmd p')
|
|
|
|
feed_command('call DoRecordScreen()')
|
2015-06-10 17:01:11 -07:00
|
|
|
|
|
|
|
-- Test, that the string " a\tb\tc\td\te" is correctly displayed in a
|
|
|
|
-- 20 column wide window (see bug report
|
|
|
|
-- https://groups.google.com/d/msg/vim_dev/ZOdg2mc9c9Y/TT8EhFjEy0IJ ).
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('only')
|
|
|
|
feed_command('vert 20new')
|
|
|
|
feed_command('set all& breakindent briopt=min:10')
|
|
|
|
feed_command([[call setline(1, [" a\tb\tc\td\te", " z y x w v"])]])
|
|
|
|
feed_command([[/^\s*a]])
|
2015-06-10 17:01:11 -07:00
|
|
|
feed('fbgjyl')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let line1 = @0')
|
|
|
|
feed_command([[?^\s*z]])
|
2015-06-10 17:01:11 -07:00
|
|
|
feed('fygjyl')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let line2 = @0')
|
|
|
|
feed_command('quit!')
|
|
|
|
feed_command([[$put ='Test 13: breakindent with wrapping Tab']])
|
|
|
|
feed_command('$put =line1')
|
|
|
|
feed_command('$put =line2')
|
|
|
|
|
|
|
|
feed_command('let g:test="Test 14: breakindent + visual blockwise delete #1"')
|
|
|
|
feed_command('set all& breakindent shada+=nX-test-breakindent.shada')
|
|
|
|
feed_command('30vnew')
|
|
|
|
feed_command('normal! 3a1234567890')
|
|
|
|
feed_command('normal! a abcde')
|
|
|
|
feed_command([[exec "normal! 0\<C-V>tex"]])
|
|
|
|
feed_command('let line1=ScreenChar(line("."),8)')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
|
|
|
|
feed_command('let g:test="Test 15: breakindent + visual blockwise delete #2"')
|
|
|
|
feed_command('%d')
|
|
|
|
feed_command('normal! 4a1234567890')
|
|
|
|
feed_command([[exec "normal! >>\<C-V>3f0x"]])
|
|
|
|
feed_command('let line1=ScreenChar(line("."),20)')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
feed_command('quit!')
|
2015-06-10 17:01:11 -07:00
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
expect([[
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 1: Simple breakindent
|
|
|
|
abcd
|
|
|
|
qrst
|
|
|
|
GHIJ
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 2: Simple breakindent + sbr=>>
|
|
|
|
abcd
|
|
|
|
>>qr
|
|
|
|
>>EF
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 3: Simple breakindent + briopt:sbr
|
|
|
|
abcd
|
|
|
|
++ qrst
|
|
|
|
++ GHIJ
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 4: Simple breakindent + min width: 18
|
|
|
|
abcd
|
|
|
|
qrstuv
|
|
|
|
IJKLMN
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 5: Simple breakindent + shift by 2
|
|
|
|
abcd
|
|
|
|
qr
|
|
|
|
EF
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 6: Simple breakindent + shift by -1
|
|
|
|
abcd
|
|
|
|
qrstu
|
|
|
|
HIJKL
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 7: breakindent + shift by +1 + nu + sbr=? briopt:sbr
|
|
|
|
2 ab
|
|
|
|
? m
|
|
|
|
? x
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 8: breakindent + shift:1 + nu + sbr=# list briopt:sbr
|
|
|
|
2 ^Iabcd
|
|
|
|
# opq
|
|
|
|
# BCD
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 9: breakindent + shift by +1 + 'nu' + sbr=# list
|
|
|
|
2 ^Iabcd
|
|
|
|
#op
|
|
|
|
#AB
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 10: breakindent + shift by +1 + 'nu' + sbr=~ cpo+=n
|
|
|
|
2 ab
|
|
|
|
~ mn
|
|
|
|
~ yz
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 11: strdisplaywidth when breakindent is on
|
|
|
|
strdisplaywidth: 46 == calculated: 64
|
|
|
|
{
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 12: breakindent + long indent
|
|
|
|
56
|
|
|
|
|
|
|
|
~
|
|
|
|
Test 13: breakindent with wrapping Tab
|
|
|
|
d
|
|
|
|
w
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 14: breakindent + visual blockwise delete #1
|
|
|
|
e
|
|
|
|
~
|
|
|
|
~
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-10 17:01:11 -07:00
|
|
|
Test 15: breakindent + visual blockwise delete #2
|
|
|
|
1234567890
|
|
|
|
~
|
|
|
|
~ ]])
|
|
|
|
end)
|
|
|
|
end)
|