robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
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 =n . clear 7local command =n . command 8local api =n . api 9local feed =n . feed 10local eq =t . eq 11 12describe ( 'matchparen' , function () 13local screen --- @type test.functional.ui.screen 14 15before_each ( function () 16clear { args ={ '-u' , 'NORC' } } 17screen =Screen . new ( 20 , 5 ) 18screen : set_default_attr_ids ( { 19[ 0 ] ={ bold =true , foreground =255 } , 20[ 1 ] ={ bold =true } , 21} ) 22end ) 23 24it ( 'uses correct column after i_<Up>. Vim patch 7.4.1296' , function () 25command ( 'set noautoindent nosmartindent nocindent laststatus=0' ) 26eq ( 1 , api . nvim_get_var ( 'loaded_matchparen' )) 27feed ( 'ivoid f_test()<cr>' ) 28feed ( '{<cr>' ) 29feed ( '}' ) 30 31-- critical part: up + cr should result in an empty line in between the 32-- brackets... if the bug is there, the empty line will be before the '{' 33feed ( '<up>' ) 34feed ( '<cr>' ) 35 36screen : expect ( [[ 37void f_test() | 38{ | 39^ | 40} | 41{1:-- INSERT --} | 42]] ) 43end ) 44 45it ( 'skips treesitter strings in another window' , function () 46api . nvim_buf_set_lines ( 0 , 0 , - 1 , false , { 'print(")")' } ) 47n . exec_lua ( function () 48vim . treesitter . start ( 0 , 'lua' ) 49end ) 50api . nvim_win_set_cursor ( 0 , { 1 , 5 } ) 51local win =api . nvim_get_current_win () 52command ( 'new' ) 53eq ( 54{ { 1 , 6 , 1 } , { 1 , 10 , 1 } } , 55n . exec_lua ( function ( target_win ) 56require ( 'nvim.matchparen' ). highlight_matching_pair ( target_win ) 57local match =vim . fn . getmatches ( target_win )[ 1 ] 58return { match . pos1 , match . pos2 } 59end , win ) 60) 61end ) 62end )