robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1-- Tests for 'listchars' display with 'list' and :list. 2 3local n =require ( 'test.functional.testnvim' )() 4local t =require ( 'test.testutil' ) 5local Screen =require ( 'test.functional.ui.screen' ) 6 7local describe , it , before_each =t . describe , t . it , t . before_each 8local feed , insert , exec =n . feed , n . insert , n . exec 9local clear , feed_command , expect =n . clear , n . feed_command , n . expect 10 11-- luacheck: ignore 621 (Indentation) 12describe ( "'listchars'" , function () 13before_each ( function () 14clear () 15feed_command ( 'set listchars=eol:$' ) 16end ) 17 18-- luacheck: ignore 613 (Trailing whitespace in a string) 19it ( "works with 'list'" , function () 20exec ( [[ 21function GetScreenCharsForLine(lnum) 22return join(map(range(1, virtcol('$')), 'nr2char(screenchar(a:lnum, v:val))'), '') 23endfunction 24nnoremap <expr> GG ":call add(g:lines, GetScreenCharsForLine(".screenrow()."))\<CR>" 25]] ) 26 27insert ( [[ 28start: 29aa 30bb 31cccc 32dd ee 33]] ) 34 35feed_command ( 'let g:lines = []' ) 36 37-- Set up 'listchars', switch on 'list', and use the "GG" mapping to record 38-- what the buffer lines look like. 39feed_command ( 'set listchars+=tab:>-,space:.,trail:<' ) 40feed_command ( 'set list' ) 41feed_command ( '/^start:/' ) 42feed_command ( 'normal! jzt' ) 43feed ( 'GG<cr>' ) 44feed ( 'GG<cr>' ) 45feed ( 'GG<cr>' ) 46feed ( 'GG<cr>' ) 47feed ( 'GGH' ) 48 49-- Repeat without displaying "trail" spaces. 50feed_command ( 'set listchars-=trail:<' ) 51feed ( 'GG<cr>' ) 52feed ( 'GG<cr>' ) 53feed ( 'GG<cr>' ) 54feed ( 'GG<cr>' ) 55feed ( 'GG' ) 56 57-- Delete the buffer contents and :put the collected lines. 58feed_command ( '%d' ) 59feed_command ( 'put =g:lines' , '1d' ) 60 61-- Assert buffer contents. 62expect ( [[ 63>-------aa>-----$ 64..bb>---<<$ 65...cccc><$ 66dd........ee<<>-$ 67$ 68>-------aa>-----$ 69..bb>---..$ 70...cccc>.$ 71dd........ee..>-$ 72$]] ) 73end ) 74 75it ( 'works with :list' , function () 76insert ( [[ 77start: 78fff 79gg 80h 81iii ]] ) 82 83-- Set up 'listchars', switch 'list' *off* (:list must show the 'listchars' 84-- even when 'list' is off), then run :list and collect the output. 85feed_command ( 'set listchars+=tab:>-,space:.,trail:<' ) 86feed_command ( 'set nolist' ) 87feed_command ( '/^start:/' ) 88feed_command ( 'redir! => g:lines' ) 89feed_command ( '+1,$list' ) 90feed_command ( 'redir END' ) 91 92-- Delete the buffer contents and :put the collected lines. 93feed_command ( '%d' ) 94feed_command ( 'put =g:lines' , '1d' ) 95 96-- Assert buffer contents. 97expect ( [[ 98 99 100..fff>--<<$ 101>-------gg>-----$ 102.....h>-$ 103iii<<<<><<$]] ) 104end ) 105 106it ( '"exceeds" character does not appear in foldcolumn vim-patch:8.2.3121' , function () 107local screen =Screen . new ( 60 , 10 ) 108exec ( [[ 109call setline(1, ['aaa', '', 'a', 'aaaaaa']) 110vsplit 111vsplit 112windo set signcolumn=yes foldcolumn=1 winminwidth=0 nowrap list listchars=extends:>,precedes:< 113]] ) 114feed ( '13<C-W>>' ) 115screen : expect ( [[ 116{7: }aaa │{7: }a{1:>}│{7: }^aaa | 117{7: } │{7: } │{7: } | 118{7: }a │{7: }a │{7: }a | 119{7: }aaaaaa │{7: }a{1:>}│{7: }aaaaaa | 120{1:~ }│{1:~ }│{1:~ }|*4 121{2:[No Name] [+] <[+] }{3:[No Name] [+] }| 122| 123]] ) 124feed ( '<C-W>>' ) 125screen : expect ( [[ 126{7: }aaa │{7: }{1:>}│{7: }^aaa | 127{7: } │{7: } │{7: } | 128{7: }a │{7: }a│{7: }a | 129{7: }aaaaaa │{7: }{1:>}│{7: }aaaaaa | 130{1:~ }│{1:~ }│{1:~ }|*4 131{2:[No Name] [+] <+] }{3:[No Name] [+] }| 132| 133]] ) 134feed ( '<C-W>>' ) 135screen : expect ( [[ 136{7: }aaa │{7: }│{7: }^aaa | 137{7: } │{7: }│{7: } | 138{7: }a │{7: }│{7: }a | 139{7: }aaaaaa │{7: }│{7: }aaaaaa | 140{1:~ }│{1:~ }│{1:~ }|*4 141{2:[No Name] [+] <] }{3:[No Name] [+] }| 142| 143]] ) 144feed ( '<C-W>>' ) 145screen : expect ( [[ 146{7: }aaa │{7: }│{7: }^aaa | 147{7: } │{7: }│{7: } | 148{7: }a │{7: }│{7: }a | 149{7: }aaaaaa │{7: }│{7: }aaaaaa | 150{1:~ }│{1:~ }│{1:~ }|*4 151{2:[No Name] [+] < }{3:[No Name] [+] }| 152| 153]] ) 154feed ( '<C-W>>' ) 155screen : expect ( [[ 156{7: }aaa │{7: }│{7: }^aaa | 157{7: } │{7: }│{7: } | 158{7: }a │{7: }│{7: }a | 159{7: }aaaaaa │{7: }│{7: }aaaaaa | 160{1:~ }│{1:~}│{1:~ }|*4 161{2:[No Name] [+] < }{3:[No Name] [+] }| 162| 163]] ) 164feed ( '<C-W>h' ) 165feed_command ( 'set nowrap foldcolumn=4' ) 166screen : expect ( [[ 167{7: }aaa │{7: }^aaa │{7: }aaa | 168{7: } │{7: } │{7: } | 169{7: }a │{7: }a │{7: }a | 170{7: }aaaaaa │{7: }aaaaaa │{7: }aaaaaa | 171{1:~ }│{1:~ }│{1:~ }|*4 172{2:[No Name] [+] }{3:[No Name] [+] }{2:[No Name] [+] }| 173:set nowrap foldcolumn=4 | 174]] ) 175feed ( '15<C-W><lt>' ) 176screen : expect ( [[ 177{7: }aaa │{7: }│{7: }aaa | 178{7: } │{7: }│{7: } | 179{7: }a │{7: }│{7: }a | 180{7: }aaaaaa │{7: ^ }│{7: }aaaaaa | 181{1:~ }│{1:~ }│{1:~ }|*4 182{2:[No Name] [+] }{3:<[+] }{2:[No Name] [+] }| 183:set nowrap foldcolumn=4 | 184]] ) 185feed ( '4<C-W><lt>' ) 186screen : expect ( [[ 187{7: }aaa │{7: }│{7: }aaa | 188{7: } │{7: }│{7: } | 189{7: }a │{7: }│{7: }a | 190{7: }aaaaaa │{7:^ }│{7: }aaaaaa | 191{1:~ }│{1:~}│{1:~ }|*4 192{2:[No Name] [+] }{3:< }{2:[No Name] [+] }| 193:set nowrap foldcolumn=4 | 194]] ) 195end ) 196end )