robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1-- Test for v:hlsearch 2 3local n =require ( 'test.functional.testnvim' )() 4local t =require ( 'test.testutil' ) 5 6local describe , it , setup =t . describe , t . it , t . setup 7local clear , feed =n . clear , n . feed 8local feed_command , expect =n . feed_command , n . expect 9 10describe ( 'v:hlsearch' , function () 11setup ( clear ) 12 13it ( 'is working' , function () 14-- Last abc: Q 15feed_command ( 'new' ) 16feed_command ( [[call setline(1, repeat(['aaa'], 10))]] ) 17feed_command ( 'set hlsearch nolazyredraw' ) 18feed_command ( 'let r=[]' ) 19feed_command ( 'command -nargs=0 -bar AddR :call add(r, [screenattr(1, 1), v:hlsearch])' ) 20feed_command ( '/aaa' ) 21feed_command ( 'AddR' ) 22feed_command ( 'nohlsearch' ) 23feed_command ( 'AddR' ) 24feed_command ( 'let v:hlsearch=1' ) 25feed_command ( 'AddR' ) 26feed_command ( 'let v:hlsearch=0' ) 27feed_command ( 'AddR' ) 28feed_command ( 'set hlsearch' ) 29feed_command ( 'AddR' ) 30feed_command ( 'let v:hlsearch=0' ) 31feed_command ( 'AddR' ) 32feed ( 'n:AddR<cr>' ) 33feed_command ( 'let v:hlsearch=0' ) 34feed_command ( 'AddR' ) 35feed_command ( '/' ) 36feed_command ( 'AddR' ) 37feed_command ( 'set nohls' ) 38feed_command ( '/' ) 39feed_command ( 'AddR' ) 40feed_command ( 'let r1=r[0][0]' ) 41 42-- I guess it is not guaranteed that screenattr outputs always the same character 43feed_command ( [[call map(r, 'v:val[1].":".(v:val[0]==r1?"highlighted":"not highlighted")')]] ) 44feed_command ( 'try' ) 45feed_command ( ' let v:hlsearch=[]' ) 46feed_command ( 'catch' ) 47feed_command ( [[ call add(r, matchstr(v:exception,'^Vim(let):E\d\+:'))]] ) 48feed_command ( 'endtry' ) 49feed_command ( 'bwipeout!' ) 50feed_command ( '$put=r' ) 51feed_command ( 'call garbagecollect(1)' ) 52feed_command ( 'call getchar()' ) 53feed_command ( '1d' , '1d' ) 54 55-- Assert buffer contents. 56expect ( [[ 571:highlighted 580:not highlighted 591:highlighted 600:not highlighted 611:highlighted 620:not highlighted 631:highlighted 640:not highlighted 651:highlighted 660:not highlighted 67Vim(let):E745:]] ) 68end ) 69end )