2015-06-11 03:33:09 -07:00
|
|
|
-- Test for linebreak and list option (non-utf8)
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2022-10-09 03:57:22 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2016-02-09 14:50:26 -07:00
|
|
|
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
2017-04-08 14:12:26 -07:00
|
|
|
local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
|
2015-06-11 03:33:09 -07:00
|
|
|
|
|
|
|
describe('listlbr', function()
|
2022-10-09 03:57:22 -07:00
|
|
|
before_each(clear)
|
2015-06-11 03:33:09 -07:00
|
|
|
|
2017-09-24 11:42:48 -07:00
|
|
|
-- luacheck: ignore 621 (Indentation)
|
|
|
|
-- luacheck: ignore 611 (Line contains only whitespaces)
|
|
|
|
-- luacheck: ignore 613 (Trailing whitespaces in a string)
|
2015-06-11 03:33:09 -07:00
|
|
|
it('is working', function()
|
2016-02-09 14:50:26 -07:00
|
|
|
insert([[
|
|
|
|
dummy text]])
|
2015-06-11 03:33:09 -07:00
|
|
|
|
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 =\"\tabcdef hijklmn\tpqrstuvwxyz_1060ABCDEFGHIJKLMNOP \"]])
|
|
|
|
feed_command('norm! zt')
|
|
|
|
feed_command('set ts=4 sw=4 sts=4 linebreak sbr=+ wrap')
|
2016-02-09 14:50:26 -07:00
|
|
|
source([[
|
|
|
|
fu! ScreenChar(width)
|
2017-09-24 11:42:48 -07:00
|
|
|
let c=''
|
|
|
|
for j in range(1,4)
|
|
|
|
for i in range(1,a:width)
|
|
|
|
let c.=nr2char(screenchar(j, i))
|
|
|
|
endfor
|
|
|
|
let c.="\n"
|
|
|
|
endfor
|
|
|
|
return c
|
2016-02-09 14:50:26 -07:00
|
|
|
endfu
|
|
|
|
fu! DoRecordScreen()
|
2017-09-24 11:42:48 -07:00
|
|
|
wincmd l
|
|
|
|
$put =printf(\"\n%s\", g:test)
|
|
|
|
$put =g:line
|
|
|
|
wincmd p
|
2016-02-09 14:50:26 -07:00
|
|
|
endfu
|
|
|
|
]])
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let g:test="Test 1: set linebreak"')
|
|
|
|
feed_command('redraw!')
|
|
|
|
feed_command('let line=ScreenChar(winwidth(0))')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
|
|
|
|
feed_command('let g:test="Test 2: set linebreak + set list"')
|
|
|
|
feed_command('set linebreak list listchars=')
|
|
|
|
feed_command('redraw!')
|
|
|
|
feed_command('let line=ScreenChar(winwidth(0))')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
|
|
|
|
feed_command('let g:test ="Test 3: set linebreak nolist"')
|
|
|
|
feed_command('set nolist linebreak')
|
|
|
|
feed_command('redraw!')
|
|
|
|
feed_command('let line=ScreenChar(winwidth(0))')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
|
|
|
|
feed_command(
|
|
|
|
'let g:test ="Test 4: set linebreak with tab and 1 line as long as screen: should break!"'
|
|
|
|
)
|
|
|
|
feed_command('set nolist linebreak ts=8')
|
|
|
|
feed_command([[let line="1\t".repeat('a', winwidth(0)-2)]])
|
|
|
|
feed_command('$put =line')
|
|
|
|
feed_command('$')
|
|
|
|
feed_command('norm! zt')
|
|
|
|
feed_command('redraw!')
|
|
|
|
feed_command('let line=ScreenChar(winwidth(0))')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
feed_command([[let line="_S_\t bla"]])
|
|
|
|
feed_command('$put =line')
|
|
|
|
feed_command('$')
|
|
|
|
feed_command('norm! zt')
|
|
|
|
|
|
|
|
feed_command(
|
|
|
|
'let g:test ="Test 5: set linebreak with conceal and set list and tab displayed by different char (line may not be truncated)"'
|
|
|
|
)
|
|
|
|
feed_command('set cpo&vim list linebreak conceallevel=2 concealcursor=nv listchars=tab:ab')
|
|
|
|
feed_command('syn match ConcealVar contained /_/ conceal')
|
|
|
|
feed_command('syn match All /.*/ contains=ConcealVar')
|
|
|
|
feed_command('let line=ScreenChar(winwidth(0))')
|
|
|
|
feed_command('call DoRecordScreen()')
|
|
|
|
feed_command('set cpo&vim linebreak')
|
|
|
|
|
|
|
|
feed_command('let g:test ="Test 6: set linebreak with visual block mode"')
|
|
|
|
feed_command('let line="REMOVE: this not"')
|
|
|
|
feed_command('$put =g:test')
|
|
|
|
feed_command('$put =line')
|
|
|
|
feed_command('let line="REMOVE: aaaaaaaaaaaaa"')
|
|
|
|
feed_command('$put =line')
|
|
|
|
feed_command('1/^REMOVE:')
|
2015-06-11 03:33:09 -07:00
|
|
|
feed('0<C-V>jf x')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('$put')
|
|
|
|
feed_command('set cpo&vim linebreak')
|
2016-02-09 14:50:26 -07:00
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let g:test ="Test 7: set linebreak with visual block mode and v_b_A"')
|
|
|
|
feed_command('$put =g:test')
|
2015-06-11 03:33:09 -07:00
|
|
|
feed('Golong line: <esc>40afoobar <esc>aTARGET at end<esc>')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command([[exe "norm! $3B\<C-v>eAx\<Esc>"]])
|
|
|
|
feed_command('set cpo&vim linebreak sbr=')
|
2016-02-09 14:50:26 -07:00
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let g:test ="Test 8: set linebreak with visual char mode and changing block"')
|
|
|
|
feed_command('$put =g:test')
|
2015-06-11 03:33:09 -07:00
|
|
|
feed('Go1111-1111-1111-11-1111-1111-1111<esc>0f-lv3lc2222<esc>bgj.')
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let g:test ="Test 9: using redo after block visual mode"')
|
|
|
|
feed_command('$put =g:test')
|
2016-02-09 14:50:26 -07:00
|
|
|
feed('Go<CR>')
|
|
|
|
feed('aaa<CR>')
|
|
|
|
feed('aaa<CR>')
|
|
|
|
feed('a<ESC>2k<C-V>2j~e.<CR>')
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let g:test ="Test 10: using normal commands after block-visual"')
|
|
|
|
feed_command('$put =g:test')
|
|
|
|
feed_command('set linebreak')
|
2016-02-09 14:50:26 -07:00
|
|
|
feed('Go<cr>')
|
|
|
|
feed('abcd{ef<cr>')
|
|
|
|
feed('ghijklm<cr>')
|
|
|
|
feed('no}pqrs<esc>2k0f{<C-V><C-V>c%<esc>')
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let g:test ="Test 11: using block replace mode after wrapping"')
|
|
|
|
feed_command('$put =g:test')
|
|
|
|
feed_command('set linebreak wrap')
|
2016-02-09 14:50:26 -07:00
|
|
|
feed('Go<esc>150aa<esc>yypk147|<C-V>jr0<cr>')
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let g:test ="Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$"')
|
|
|
|
feed_command('set list listchars=space:_,trail:-,tab:>-,eol:$')
|
|
|
|
feed_command('$put =g:test')
|
|
|
|
feed_command([[let line="a aaaaaaaaaaaaaaaaaaaaaa\ta "]])
|
|
|
|
feed_command('$put =line')
|
|
|
|
feed_command('$')
|
|
|
|
feed_command('norm! zt')
|
|
|
|
feed_command('redraw!')
|
|
|
|
feed_command('let line=ScreenChar(winwidth(0))')
|
|
|
|
feed_command('call DoRecordScreen()')
|
2016-02-09 14:50:26 -07:00
|
|
|
|
2015-06-11 03:33:09 -07:00
|
|
|
-- Assert buffer contents.
|
2016-02-09 14:50:26 -07:00
|
|
|
expect([[
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-11 03:33:09 -07:00
|
|
|
abcdef hijklmn pqrstuvwxyz_1060ABCDEFGHIJKLMNOP
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-11 03:33:09 -07:00
|
|
|
Test 1: set linebreak
|
|
|
|
abcdef
|
|
|
|
+hijklmn
|
|
|
|
+pqrstuvwxyz_1060ABC
|
|
|
|
+DEFGHIJKLMNOP
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-11 03:33:09 -07:00
|
|
|
Test 2: set linebreak + set list
|
|
|
|
^Iabcdef hijklmn^I
|
|
|
|
+pqrstuvwxyz_1060ABC
|
|
|
|
+DEFGHIJKLMNOP
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-11 03:33:09 -07:00
|
|
|
Test 3: set linebreak nolist
|
|
|
|
abcdef
|
|
|
|
+hijklmn
|
|
|
|
+pqrstuvwxyz_1060ABC
|
|
|
|
+DEFGHIJKLMNOP
|
|
|
|
1 aaaaaaaaaaaaaaaaaa
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-11 03:33:09 -07:00
|
|
|
Test 4: set linebreak with tab and 1 line as long as screen: should break!
|
|
|
|
1
|
|
|
|
+aaaaaaaaaaaaaaaaaa
|
|
|
|
~
|
|
|
|
~
|
|
|
|
_S_ bla
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-06-11 03:33:09 -07:00
|
|
|
Test 5: set linebreak with conceal and set list and tab displayed by different char (line may not be truncated)
|
|
|
|
Sabbbbbb bla
|
|
|
|
~
|
|
|
|
~
|
|
|
|
~
|
|
|
|
Test 6: set linebreak with visual block mode
|
|
|
|
this not
|
|
|
|
aaaaaaaaaaaaa
|
|
|
|
REMOVE:
|
|
|
|
REMOVE:
|
|
|
|
Test 7: set linebreak with visual block mode and v_b_A
|
|
|
|
long line: foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar TARGETx at end
|
|
|
|
Test 8: set linebreak with visual char mode and changing block
|
2016-02-09 14:50:26 -07:00
|
|
|
1111-2222-1111-11-1111-2222-1111
|
|
|
|
Test 9: using redo after block visual mode
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2016-02-09 14:50:26 -07:00
|
|
|
AaA
|
|
|
|
AaA
|
|
|
|
A
|
|
|
|
Test 10: using normal commands after block-visual
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2016-02-09 14:50:26 -07:00
|
|
|
abcdpqrs
|
|
|
|
Test 11: using block replace mode after wrapping
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0aaa
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0aaa
|
|
|
|
Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$
|
|
|
|
a aaaaaaaaaaaaaaaaaaaaaa a
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2016-02-09 14:50:26 -07:00
|
|
|
Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$
|
|
|
|
a_
|
|
|
|
aaaaaaaaaaaaaaaaaaaa
|
|
|
|
aa>-----a-$
|
|
|
|
~ ]])
|
2015-06-11 03:33:09 -07:00
|
|
|
end)
|
2022-10-09 03:57:22 -07:00
|
|
|
|
|
|
|
-- oldtest: Test_linebreak_reset_restore()
|
|
|
|
it('cursor position is drawn correctly after operator', function()
|
|
|
|
local screen = Screen.new(60, 6)
|
|
|
|
screen:attach()
|
|
|
|
|
|
|
|
-- f_wincol() calls validate_cursor()
|
|
|
|
source([[
|
|
|
|
set linebreak showcmd noshowmode formatexpr=wincol()-wincol()
|
|
|
|
call setline(1, repeat('a', &columns - 10) .. ' bbbbbbbbbb c')
|
|
|
|
]])
|
|
|
|
|
|
|
|
feed('$v$')
|
|
|
|
screen:expect([[
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
|
2024-03-27 02:35:50 -07:00
|
|
|
bbbbbbbbbb {17:c}^ |
|
|
|
|
{1:~ }|*3
|
2022-10-09 03:57:22 -07:00
|
|
|
2 |
|
|
|
|
]])
|
|
|
|
feed('zo')
|
|
|
|
screen:expect([[
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
|
|
|
|
bbbbbbbbbb ^c |
|
2024-03-27 02:35:50 -07:00
|
|
|
{1:~ }|*3
|
|
|
|
{9:E490: No fold found} |
|
2022-10-09 03:57:22 -07:00
|
|
|
]])
|
|
|
|
|
|
|
|
feed('$v$')
|
|
|
|
screen:expect([[
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
|
2024-03-27 02:35:50 -07:00
|
|
|
bbbbbbbbbb {17:c}^ |
|
|
|
|
{1:~ }|*3
|
|
|
|
{9:E490: No fold found} 2 |
|
2022-10-09 03:57:22 -07:00
|
|
|
]])
|
|
|
|
feed('gq')
|
|
|
|
screen:expect([[
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
|
|
|
|
bbbbbbbbbb ^c |
|
2024-03-27 02:35:50 -07:00
|
|
|
{1:~ }|*3
|
|
|
|
{9:E490: No fold found} |
|
2022-10-09 03:57:22 -07:00
|
|
|
]])
|
|
|
|
|
|
|
|
feed('$<C-V>$')
|
|
|
|
screen:expect([[
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
|
2024-03-27 02:35:50 -07:00
|
|
|
bbbbbbbbbb {17:c}^ |
|
|
|
|
{1:~ }|*3
|
|
|
|
{9:E490: No fold found} 1x2 |
|
2022-10-09 03:57:22 -07:00
|
|
|
]])
|
|
|
|
feed('I')
|
|
|
|
screen:expect([[
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
|
|
|
|
bbbbbbbbbb ^c |
|
2024-03-27 02:35:50 -07:00
|
|
|
{1:~ }|*3
|
|
|
|
{9:E490: No fold found} |
|
2022-10-09 03:57:22 -07:00
|
|
|
]])
|
|
|
|
|
|
|
|
feed('<Esc>$v$')
|
|
|
|
screen:expect([[
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
|
2024-03-27 02:35:50 -07:00
|
|
|
bbbbbbbbbb {17:c}^ |
|
|
|
|
{1:~ }|*3
|
|
|
|
{9:E490: No fold found} 2 |
|
2022-10-09 03:57:22 -07:00
|
|
|
]])
|
|
|
|
feed('s')
|
|
|
|
screen:expect([[
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
|
|
|
|
bbbbbbbbbb ^ |
|
2024-03-27 02:35:50 -07:00
|
|
|
{1:~ }|*3
|
|
|
|
{9:E490: No fold found} |
|
2022-10-09 03:57:22 -07:00
|
|
|
]])
|
|
|
|
end)
|
2015-06-11 03:33:09 -07:00
|
|
|
end)
|