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 eq =t . eq 7local dedent =t . dedent 8local exec =n . exec 9local feed =n . feed 10local clear =n . clear 11local command =n . command 12local api =n . api 13 14local cmdtest =function ( cmd , prep , ret1 ) 15describe ( ':' .. cmd , function () 16before_each ( function () 17clear () 18api . nvim_buf_set_lines ( 0 , 0 , 1 , true , { 'foo' , 'bar' , 'baz' } ) 19end ) 20 21local buffer_contents =function () 22return api . nvim_buf_get_lines ( 0 , 0 , - 1 , false ) 23end 24 25it ( cmd .. 's' .. prep .. ' the current line by default' , function () 26command ( cmd .. '\nabc\ndef' ) 27eq ( ret1 , buffer_contents ()) 28end ) 29-- Used to crash because this invokes history processing which uses 30-- hist_char2type which after fdb68e35e4c729c7ed097d8ade1da29e5b3f4b31 31-- crashed. 32it ( cmd .. 's' .. prep .. ' the current line by default when feeding' , function () 33feed ( ':' .. cmd .. '\nabc\ndef\n.\n' ) 34eq ( ret1 , buffer_contents ()) 35end ) 36end ) 37end 38cmdtest ( 'insert' , ' before' , { 'abc' , 'def' , 'foo' , 'bar' , 'baz' } ) 39cmdtest ( 'append' , ' after' , { 'foo' , 'abc' , 'def' , 'bar' , 'baz' } ) 40cmdtest ( 'change' , '' , { 'abc' , 'def' , 'bar' , 'baz' } ) 41 42describe ( 'first line is redrawn correctly after :append/:insert in an empty buffer' , function () 43local screen 44before_each ( function () 45clear () 46screen =Screen . new ( 20 , 8 ) 47screen : set_default_attr_ids ( { 48[ 1 ] ={ bold =true , foreground =Screen . colors . Blue } , 49[ 2 ] ={ bold =true , reverse =true } , 50} ) 51end ) 52 53it ( 'using :append' , function () 54exec ( dedent ( [[ 55append 56aaaaa 57bbbbb 58.]] )) 59screen : expect ( [[ 60aaaaa | 61^bbbbb | 62{1:~ }|*5 63| 64]] ) 65end ) 66 67it ( 'using :insert' , function () 68exec ( dedent ( [[ 69insert 70aaaaa 71bbbbb 72.]] )) 73screen : expect ( [[ 74aaaaa | 75^bbbbb | 76{1:~ }|*5 77| 78]] ) 79end ) 80end )