robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1-- Tests for signs 2 3local n =require ( 'test.functional.testnvim' )() 4local t =require ( 'test.testutil' ) 5local Screen =require ( 'test.functional.ui.screen' ) 6 7local describe , it , before_each =t . describe , t . it , t . before_each 8local clear , command , exec , expect , feed =n . clear , n . command , n . exec , n . expect , n . feed 9 10describe ( 'signs' , function () 11before_each ( clear ) 12 13it ( 'are working' , function () 14command ( 'sign define JumpSign text=x' ) 15command ( [[exe 'sign place 42 line=2 name=JumpSign buffer=' . bufnr('')]] ) 16-- Split the window to the bottom to verify :sign-jump will stay in the current 17-- window if the buffer is displayed there. 18command ( 'bot split' ) 19command ( [[exe 'sign jump 42 buffer=' . bufnr('')]] ) 20command ( [[call append(line('$'), winnr())]] ) 21 22-- Assert buffer contents. 23expect ( [[ 24 252]] ) 26end ) 27 28-- oldtest: Test_sign_cursor_position() 29it ( 'are drawn correctly' , function () 30local screen =Screen . new ( 75 , 6 ) 31screen : add_extra_attr_ids ( { 32[ 100 ] ={ foreground =Screen . colors . Blue4 , background =Screen . colors . Yellow } , 33} ) 34exec ( [[ 35call setline(1, [repeat('x', 75), 'mmmm', 'yyyy']) 36call cursor(2,1) 37sign define s1 texthl=Search text==> 38sign define s2 linehl=Pmenu 39redraw 40sign place 10 line=2 name=s1 41]] ) 42screen : expect ( [[ 43{7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| 44{7: }xx | 45{100:=>}^mmmm | 46{7: }yyyy | 47{1:~ }| 48| 49]] ) 50 51-- Change the sign text 52command ( 'sign define s1 text=-)' ) 53screen : expect ( [[ 54{7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| 55{7: }xx | 56{100:-)}^mmmm | 57{7: }yyyy | 58{1:~ }| 59| 60]] ) 61 62-- Also place a line HL sign 63command ( 'sign place 11 line=2 name=s2' ) 64screen : expect ( [[ 65{7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| 66{7: }xx | 67{100:-)}{4:^mmmm }| 68{7: }yyyy | 69{1:~ }| 70| 71]] ) 72 73-- update cursor position calculation 74feed ( 'lh' ) 75command ( 'sign unplace 11' ) 76command ( 'sign unplace 10' ) 77screen : expect ( [[ 78xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| 79^mmmm | 80yyyy | 81{1:~ }|*2 82| 83]] ) 84end ) 85end )