robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
e5aac37eb3
master
1local n =require ( 'test.functional.testnvim' )() 2local t =require ( 'test.testutil' ) 3local Screen =require ( 'test.functional.ui.screen' ) 4 5local describe , it , before_each =t . describe , t . it , t . before_each 6local clear =n . clear 7local exec =n . exec 8local feed =n . feed 9 10before_each ( clear ) 11 12describe ( 'statusline' , function () 13local screen 14 15before_each ( function () 16screen =Screen . new ( 50 , 7 ) 17screen : add_extra_attr_ids ( { 18[ 100 ] ={ 19background =Screen . colors . Red , 20foreground =Screen . colors . Gray100 , 21reverse =true , 22bold =true , 23} , 24[ 101 ] ={ foreground =Screen . colors . Blue , reverse =true , bold =true } , 25} ) 26end ) 27 28it ( 'is updated in cmdline mode when using window-local statusline vim-patch:8.2.2737' , function () 29exec ( [[ 30setlocal statusline=-%{mode()}- 31split 32setlocal statusline=+%{mode()}+ 33]] ) 34screen : expect ( [[ 35^ | 36{1:~ }| 37{3:+n+ }| 38| 39{1:~ }| 40{2:-n- }| 41| 42]] ) 43feed ( ':' ) 44screen : expect ( [[ 45| 46{1:~ }| 47{3:+c+ }| 48| 49{1:~ }| 50{2:-c- }| 51:^ | 52]] ) 53end ) 54 55it ( 'truncated item does not cause off-by-one highlight vim-patch:8.2.4929' , function () 56exec ( [[ 57set laststatus=2 58hi! link User1 Directory 59hi! link User2 ErrorMsg 60set statusline=%.5(%1*ABC%2*DEF%1*GHI%) 61]] ) 62screen : expect ( [[ 63^ | 64{1:~ }|*4 65{100:<F}{101:GHI }| 66| 67]] ) 68end ) 69 70-- oldtest: Test_statusline_showcmd() 71it ( 'showcmdloc=statusline works' , function () 72exec ( [[ 73func MyStatusLine() 74return '%S' 75endfunc 76 77set showcmd 78set laststatus=2 79set statusline=%S 80set showcmdloc=statusline 81call setline(1, ['a', 'b', 'c']) 82set foldopen+=jump 831,2fold 843 85]] ) 86 87feed ( 'g' ) 88screen : expect ( [[ 89{13:+-- 2 lines: a···································}| 90^c | 91{1:~ }|*3 92{3:g }| 93| 94]] ) 95 96-- typing "gg" should open the fold 97feed ( 'g' ) 98screen : expect ( [[ 99^a | 100b | 101c | 102{1:~ }|*2 103{3: }| 104| 105]] ) 106 107feed ( '<C-V>Gl' ) 108screen : expect ( [[ 109{17:a} | 110{17:b} | 111{17:c}^ | 112{1:~ }|*2 113{3:3x2 }| 114{5:-- VISUAL BLOCK --} | 115]] ) 116 117feed ( '<Esc>1234' ) 118screen : expect ( [[ 119a | 120b | 121^c | 122{1:~ }|*2 123{3:1234 }| 124| 125]] ) 126 127feed ( '<Esc>:set statusline=<CR>' ) 128feed ( ':<CR>' ) 129feed ( '1234' ) 130screen : expect ( [[ 131a | 132b | 133^c | 134{1:~ }|*2 135{3:[No Name] [+] 1234 }| 136: | 137]] ) 138end ) 139 140-- oldtest: Test_statusline_showcmd_nop_map() 141it ( 'showcmdloc=statusline is redrawn with timeout and <Nop> mapping' , function () 142exec ( [[ 143set timeoutlen=500 showcmd showcmdloc=statusline laststatus=2 144nnoremap <space> <nop> 145nnoremap <space><space> <nop> 146]] ) 147feed ( ' ' ) 148screen : expect ( { any ='<20>' , timeout =400 } ) 149vim . uv . sleep ( 500 ) 150screen : expect ( { none ='<20>' , timeout =400 } ) 151end ) 152end )