robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
3.6 KiB85 linesraw
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()
11  before_each(clear)
12
13  it('are working', function()
14    command('sign define JumpSign text=x')
15    command([[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.
18    command('bot split')
19    command([[exe 'sign jump 42 buffer=' . bufnr('')]])
20    command([[call append(line('$'), winnr())]])
21
22    -- Assert buffer contents.
23    expect([[
24
25      2]])
26  end)
27
28  -- oldtest: Test_sign_cursor_position()
29  it('are drawn correctly', function()
30    local screen = Screen.new(75, 6)
31    screen:add_extra_attr_ids({
32      [100] = { foreground = Screen.colors.Blue4, background = Screen.colors.Yellow },
33    })
34    exec([[
35      call setline(1, [repeat('x', 75), 'mmmm', 'yyyy'])
36      call cursor(2,1)
37      sign define s1 texthl=Search text==>
38      sign define s2 linehl=Pmenu
39      redraw
40      sign place 10 line=2 name=s1
41    ]])
42    screen:expect([[
43      {7:  }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
44      {7:  }xx                                                                       |
45      {100:=>}^mmmm                                                                     |
46      {7:  }yyyy                                                                     |
47      {1:~                                                                          }|
48                                                                                 |
49    ]])
50
51    -- Change the sign text
52    command('sign define s1 text=-)')
53    screen: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
63    command('sign place 11 line=2 name=s2')
64    screen:expect([[
65      {7:  }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
66      {7:  }xx                                                                       |
67      {100:-)}{4:^mmmm                                                                     }|
68      {7:  }yyyy                                                                     |
69      {1:~                                                                          }|
70                                                                                 |
71    ]])
72
73    -- update cursor position calculation
74    feed('lh')
75    command('sign unplace 11')
76    command('sign unplace 10')
77    screen:expect([[
78      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
79      ^mmmm                                                                       |
80      yyyy                                                                       |
81      {1:~                                                                          }|*2
82                                                                                 |
83    ]])
84  end)
85end)