robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3local Screen =require ( 'test.functional.ui.screen' ) 4 5local describe , it , before_each =t . describe , t . it , t . before_each 6local clear , command =n . clear , n . command 7local pcall_err =t . pcall_err 8local eval =n . eval 9local eq =t . eq 10local insert =n . insert 11local feed =n . feed 12local api =n . api 13 14describe ( "'fillchars'" , function () 15local screen 16 17before_each ( function () 18clear () 19screen =Screen . new ( 25 , 5 ) 20end ) 21 22describe ( '"eob" flag' , function () 23it ( "uses '~' by default" , function () 24eq ( '' , eval ( '&fillchars' )) 25screen : expect ( [[ 26^ | 27{1:~ }|*3 28| 29]] ) 30end ) 31 32it ( 'supports whitespace' , function () 33screen : expect ( [[ 34^ | 35{1:~ }|*3 36| 37]] ) 38command ( 'set fillchars=eob:\\ ' ) 39screen : expect ( [[ 40^ | 41{1: }|*3 42| 43]] ) 44end ) 45 46it ( 'supports multibyte char' , function () 47command ( 'set fillchars=eob:ñ' ) 48screen : expect ( [[ 49^ | 50{1:ñ }|*3 51| 52]] ) 53end ) 54 55it ( 'supports composing multibyte char' , function () 56command ( 'set fillchars=eob:å̲' ) 57screen : expect ( [[ 58^ | 59{1:å̲ }|*3 60| 61]] ) 62end ) 63 64it ( 'handles invalid values' , function () 65eq ( 66'Vim(set):E1511: Wrong number of characters for field "eob": fillchars=eob:' , 67pcall_err ( command , 'set fillchars=eob:' ) -- empty string 68) 69eq ( 70'Vim(set):E1512: Wrong character width for field "eob": fillchars=eob:馬' , 71pcall_err ( command , 'set fillchars=eob:馬' ) -- doublewidth char 72) 73eq ( 74'Vim(set):E1511: Wrong number of characters for field "eob": fillchars=eob:xy' , 75pcall_err ( command , 'set fillchars=eob:xy' ) -- two ascii chars 76) 77eq ( 78'Vim(set):E1512: Wrong character width for field "eob": fillchars=eob:<ff>' , 79pcall_err ( command , 'set fillchars=eob:\255' ) -- invalid UTF-8 80) 81end ) 82end ) 83 84it ( '"diff" flag' , function () 85screen : try_resize ( 45 , 8 ) 86screen : set_default_attr_ids ( { 87[ 1 ] ={ background =Screen . colors . Grey , foreground =Screen . colors . DarkBlue } , 88[ 2 ] ={ background =Screen . colors . LightCyan1 , bold =true , foreground =Screen . colors . Blue1 } , 89[ 3 ] ={ background =Screen . colors . LightBlue } , 90[ 4 ] ={ reverse =true } , 91[ 5 ] ={ reverse =true , bold =true } , 92} ) 93command ( 'set fillchars=diff:…' ) 94insert ( 'a\nb\nc\nd\ne' ) 95command ( 'vnew' ) 96insert ( 'a\nd\ne\nf' ) 97command ( 'windo diffthis' ) 98screen : expect ( [[ 99{1: }a │{1: }a | 100{1: }{2:……………………………………………………}│{1: }{3:b }| 101{1: }{2:……………………………………………………}│{1: }{3:c }| 102{1: }d │{1: }d | 103{1: }e │{1: }^e | 104{1: }{3:f }│{1: }{2:……………………………………………………}| 105{4:[No Name] [+] }{5:[No Name] [+] }| 106| 107]] ) 108end ) 109 110it ( 'has global value' , function () 111screen : try_resize ( 50 , 5 ) 112insert ( 'foo\nbar' ) 113command ( 'set laststatus=0' ) 114command ( '1,2fold' ) 115command ( 'vsplit' ) 116command ( 'set fillchars=fold:x' ) 117screen : expect ( [[ 118{13:^+-- 2 lines: fooxxxxxxxx}│{13:+-- 2 lines: fooxxxxxxx}| 119{1:~ }│{1:~ }|*3 120| 121]] ) 122end ) 123 124it ( 'has window-local value' , function () 125screen : try_resize ( 50 , 5 ) 126insert ( 'foo\nbar' ) 127command ( 'set laststatus=0' ) 128command ( '1,2fold' ) 129command ( 'vsplit' ) 130command ( 'setl fillchars=fold:x' ) 131screen : expect ( [[ 132{13:^+-- 2 lines: fooxxxxxxxx}│{13:+-- 2 lines: foo·······}| 133{1:~ }│{1:~ }|*3 134| 135]] ) 136end ) 137 138it ( 'using :set clears window-local value' , function () 139screen : try_resize ( 50 , 5 ) 140insert ( 'foo\nbar' ) 141command ( 'set laststatus=0' ) 142command ( 'setl fillchars=fold:x' ) 143command ( '1,2fold' ) 144command ( 'vsplit' ) 145command ( 'set fillchars&' ) 146screen : expect ( [[ 147{13:^+-- 2 lines: foo········}│{13:+-- 2 lines: fooxxxxxxx}| 148{1:~ }│{1:~ }|*3 149| 150]] ) 151end ) 152end ) 153 154describe ( "'listchars'" , function () 155local screen 156 157before_each ( function () 158clear () 159screen =Screen . new ( 50 , 5 ) 160end ) 161 162it ( 'has global value' , function () 163feed ( 'i<tab><tab><tab><esc>' ) 164command ( 'set list laststatus=0' ) 165command ( 'vsplit' ) 166command ( 'set listchars=tab:<->' ) 167screen : expect ( [[ 168{1:<------><------>^<------>} │{1:<------><------><------>}| 169{1:~ }│{1:~ }|*3 170| 171]] ) 172end ) 173 174it ( 'has window-local value' , function () 175feed ( 'i<tab><tab><tab><esc>' ) 176command ( 'set list laststatus=0' ) 177command ( 'setl listchars=tab:<->' ) 178command ( 'vsplit' ) 179command ( 'setl listchars<' ) 180screen : expect ( [[ 181{1:> > ^> } │{1:<------><------><------>}| 182{1:~ }│{1:~ }|*3 183| 184]] ) 185end ) 186 187it ( 'using :set clears window-local value' , function () 188feed ( 'i<tab><tab><tab><esc>' ) 189command ( 'set list laststatus=0' ) 190command ( 'setl listchars=tab:<->' ) 191command ( 'vsplit' ) 192command ( 'set listchars=tab:>-,eol:$' ) 193screen : expect ( [[ 194{1:>------->-------^>-------$}│{1:<------><------><------>}| 195{1:~ }│{1:~ }|*3 196| 197]] ) 198end ) 199 200it ( 'supports composing chars' , function () 201screen : set_default_attr_ids { 202[ 1 ] ={ foreground =Screen . colors . Blue1 , bold =true } , 203} 204feed ( 'i<tab><tab><tab>x<esc>' ) 205command ( 'set list laststatus=0' ) 206-- tricky: the tab value forms three separate one-cell chars, 207-- thus it should be accepted despite being a mess. 208command ( 'set listchars=tab:d̞̄̃̒̉̎ò́̌̌̂̐l̞̀̄̆̌̚,eol:å̲' ) 209screen : expect ( [[ 210{1:d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚}^x{1:å̲} | 211{1:~ }|*3 212| 213]] ) 214 215api . nvim__invalidate_glyph_cache () 216screen : _reset () 217screen : expect ( [[ 218{1:d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚}^x{1:å̲} | 219{1:~ }|*3 220| 221]] ) 222end ) 223end )