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