2015-04-22 21:58:20 -07:00
|
|
|
-- Tests for 'listchars' display with 'list' and :list.
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2022-01-21 03:16:16 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
|
|
|
local feed, insert, exec = helpers.feed, helpers.insert, helpers.exec
|
2017-04-08 14:12:26 -07:00
|
|
|
local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
|
2015-04-22 21:58:20 -07:00
|
|
|
|
2017-09-24 11:42:48 -07:00
|
|
|
-- luacheck: ignore 621 (Indentation)
|
2015-04-22 21:58:20 -07:00
|
|
|
describe("'listchars'", function()
|
2015-06-20 13:16:10 -07:00
|
|
|
before_each(function()
|
|
|
|
clear()
|
2021-07-13 10:12:08 -07:00
|
|
|
feed_command('set listchars=eol:$')
|
2015-06-20 13:16:10 -07:00
|
|
|
end)
|
2015-04-22 21:58:20 -07:00
|
|
|
|
2017-09-24 11:42:48 -07:00
|
|
|
-- luacheck: ignore 613 (Trailing whitespace in a string)
|
2015-04-22 21:58:20 -07:00
|
|
|
it("works with 'list'", function()
|
2022-01-21 03:16:16 -07:00
|
|
|
exec([[
|
2015-04-22 21:58:20 -07:00
|
|
|
function GetScreenCharsForLine(lnum)
|
|
|
|
return join(map(range(1, virtcol('$')), 'nr2char(screenchar(a:lnum, v:val))'), '')
|
|
|
|
endfunction
|
|
|
|
nnoremap <expr> GG ":call add(g:lines, GetScreenCharsForLine(".screenrow()."))\<CR>"
|
|
|
|
]])
|
|
|
|
|
|
|
|
insert([[
|
|
|
|
start:
|
|
|
|
aa
|
|
|
|
bb
|
|
|
|
cccc
|
|
|
|
dd ee
|
|
|
|
]])
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let g:lines = []')
|
2015-04-22 21:58:20 -07:00
|
|
|
|
|
|
|
-- Set up 'listchars', switch on 'list', and use the "GG" mapping to record
|
|
|
|
-- what the buffer lines look like.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('set listchars+=tab:>-,space:.,trail:<')
|
|
|
|
feed_command('set list')
|
|
|
|
feed_command('/^start:/')
|
|
|
|
feed_command('normal! jzt')
|
2015-04-22 21:58:20 -07:00
|
|
|
feed('GG<cr>')
|
|
|
|
feed('GG<cr>')
|
|
|
|
feed('GG<cr>')
|
|
|
|
feed('GG<cr>')
|
|
|
|
feed('GGH')
|
|
|
|
|
|
|
|
-- Repeat without displaying "trail" spaces.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('set listchars-=trail:<')
|
2015-04-22 21:58:20 -07:00
|
|
|
feed('GG<cr>')
|
|
|
|
feed('GG<cr>')
|
|
|
|
feed('GG<cr>')
|
|
|
|
feed('GG<cr>')
|
|
|
|
feed('GG')
|
|
|
|
|
|
|
|
-- Delete the buffer contents and :put the collected lines.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('%d')
|
|
|
|
feed_command('put =g:lines', '1d')
|
2015-04-22 21:58:20 -07:00
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
expect([[
|
|
|
|
>-------aa>-----$
|
|
|
|
..bb>---<<$
|
|
|
|
...cccc><$
|
|
|
|
dd........ee<<>-$
|
|
|
|
<$
|
|
|
|
>-------aa>-----$
|
|
|
|
..bb>---..$
|
|
|
|
...cccc>.$
|
|
|
|
dd........ee..>-$
|
|
|
|
.$]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('works with :list', function()
|
|
|
|
insert([[
|
|
|
|
start:
|
|
|
|
fff
|
|
|
|
gg
|
|
|
|
h
|
|
|
|
iii ]])
|
|
|
|
|
|
|
|
-- Set up 'listchars', switch 'list' *off* (:list must show the 'listchars'
|
|
|
|
-- even when 'list' is off), then run :list and collect the output.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('set listchars+=tab:>-,space:.,trail:<')
|
|
|
|
feed_command('set nolist')
|
|
|
|
feed_command('/^start:/')
|
|
|
|
feed_command('redir! => g:lines')
|
|
|
|
feed_command('+1,$list')
|
|
|
|
feed_command('redir END')
|
2015-04-22 21:58:20 -07:00
|
|
|
|
|
|
|
-- Delete the buffer contents and :put the collected lines.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('%d')
|
|
|
|
feed_command('put =g:lines', '1d')
|
2015-04-22 21:58:20 -07:00
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
expect([[
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
2015-04-22 21:58:20 -07:00
|
|
|
..fff>--<<$
|
|
|
|
>-------gg>-----$
|
|
|
|
.....h>-$
|
|
|
|
iii<<<<><<$]])
|
|
|
|
end)
|
2022-01-21 03:16:16 -07:00
|
|
|
|
|
|
|
it('"exceeds" character does not appear in foldcolumn vim-patch:8.2.3121', function()
|
|
|
|
local screen = Screen.new(60, 10)
|
2022-03-31 16:11:38 -07:00
|
|
|
screen:set_default_attr_ids({
|
2024-01-02 18:09:18 -07:00
|
|
|
[1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
|
|
|
|
[2] = { bold = true, reverse = true }, -- StatusLine
|
|
|
|
[3] = { reverse = true }, -- StatusLineNC
|
|
|
|
[4] = { background = Screen.colors.Grey, foreground = Screen.colors.DarkBlue }, -- FoldColumn, SignColumn
|
2022-03-31 16:11:38 -07:00
|
|
|
})
|
2022-01-21 03:16:16 -07:00
|
|
|
screen:attach()
|
|
|
|
exec([[
|
|
|
|
call setline(1, ['aaa', '', 'a', 'aaaaaa'])
|
|
|
|
vsplit
|
|
|
|
vsplit
|
|
|
|
windo set signcolumn=yes foldcolumn=1 winminwidth=0 nowrap list listchars=extends:>,precedes:<
|
|
|
|
]])
|
|
|
|
feed('13<C-W>>')
|
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
{4: }aaa │{4: }a{1:>}│{4: }^aaa |
|
|
|
|
{4: } │{4: } │{4: } |
|
|
|
|
{4: }a │{4: }a │{4: }a |
|
|
|
|
{4: }aaaaaa │{4: }a{1:>}│{4: }aaaaaa |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }│{1:~ }│{1:~ }|*4
|
2022-03-31 16:11:38 -07:00
|
|
|
{3:[No Name] [+] <[+] }{2:[No Name] [+] }|
|
2022-01-21 03:16:16 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('<C-W>>')
|
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
{4: }aaa │{4: }{1:>}│{4: }^aaa |
|
|
|
|
{4: } │{4: } │{4: } |
|
|
|
|
{4: }a │{4: }a│{4: }a |
|
|
|
|
{4: }aaaaaa │{4: }{1:>}│{4: }aaaaaa |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }│{1:~ }│{1:~ }|*4
|
2022-03-31 16:11:38 -07:00
|
|
|
{3:[No Name] [+] <+] }{2:[No Name] [+] }|
|
2022-01-21 03:16:16 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('<C-W>>')
|
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
{4: }aaa │{4: }│{4: }^aaa |
|
|
|
|
{4: } │{4: }│{4: } |
|
|
|
|
{4: }a │{4: }│{4: }a |
|
|
|
|
{4: }aaaaaa │{4: }│{4: }aaaaaa |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }│{1:~ }│{1:~ }|*4
|
2022-03-31 16:11:38 -07:00
|
|
|
{3:[No Name] [+] <] }{2:[No Name] [+] }|
|
2022-01-21 03:16:16 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('<C-W>>')
|
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
{4: }aaa │{4: }│{4: }^aaa |
|
|
|
|
{4: } │{4: }│{4: } |
|
|
|
|
{4: }a │{4: }│{4: }a |
|
|
|
|
{4: }aaaaaa │{4: }│{4: }aaaaaa |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }│{1:~ }│{1:~ }|*4
|
2022-03-31 16:11:38 -07:00
|
|
|
{3:[No Name] [+] < }{2:[No Name] [+] }|
|
2022-01-21 03:16:16 -07:00
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('<C-W>>')
|
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
{4: }aaa │{4: }│{4: }^aaa |
|
|
|
|
{4: } │{4: }│{4: } |
|
|
|
|
{4: }a │{4: }│{4: }a |
|
|
|
|
{4: }aaaaaa │{4: }│{4: }aaaaaa |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }│{1:~}│{1:~ }|*4
|
2022-03-31 16:11:38 -07:00
|
|
|
{3:[No Name] [+] < }{2:[No Name] [+] }|
|
2022-01-21 03:16:16 -07:00
|
|
|
|
|
|
|
|
]])
|
2022-03-31 16:11:38 -07:00
|
|
|
feed('<C-W>h')
|
|
|
|
feed_command('set nowrap foldcolumn=4')
|
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
{4: }aaa │{4: }^aaa │{4: }aaa |
|
|
|
|
{4: } │{4: } │{4: } |
|
|
|
|
{4: }a │{4: }a │{4: }a |
|
|
|
|
{4: }aaaaaa │{4: }aaaaaa │{4: }aaaaaa |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }│{1:~ }│{1:~ }|*4
|
2022-03-31 16:11:38 -07:00
|
|
|
{3:[No Name] [+] }{2:[No Name] [+] }{3:[No Name] [+] }|
|
|
|
|
:set nowrap foldcolumn=4 |
|
|
|
|
]])
|
|
|
|
feed('15<C-W><lt>')
|
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
{4: }aaa │{4: }│{4: }aaa |
|
|
|
|
{4: } │{4: }│{4: } |
|
|
|
|
{4: }a │{4: }│{4: }a |
|
|
|
|
{4: }aaaaaa │{4: ^ }│{4: }aaaaaa |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }│{1:~ }│{1:~ }|*4
|
2022-03-31 16:11:38 -07:00
|
|
|
{3:[No Name] [+] }{2:<[+] }{3:[No Name] [+] }|
|
|
|
|
:set nowrap foldcolumn=4 |
|
|
|
|
]])
|
|
|
|
feed('4<C-W><lt>')
|
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
{4: }aaa │{4: }│{4: }aaa |
|
|
|
|
{4: } │{4: }│{4: } |
|
|
|
|
{4: }a │{4: }│{4: }a |
|
|
|
|
{4: }aaaaaa │{4:^ }│{4: }aaaaaa |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }│{1:~}│{1:~ }|*4
|
2022-03-31 16:11:38 -07:00
|
|
|
{3:[No Name] [+] }{2:< }{3:[No Name] [+] }|
|
|
|
|
:set nowrap foldcolumn=4 |
|
|
|
|
]])
|
2022-01-21 03:16:16 -07:00
|
|
|
end)
|
2015-04-22 21:58:20 -07:00
|
|
|
end)
|