2014-12-27 14:36:58 -07:00
|
|
|
-- Tests for signs
|
|
|
|
|
2024-04-20 08:44:13 -07:00
|
|
|
local n = require('test.functional.testnvim')()
|
2024-07-16 17:53:10 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2024-04-20 08:44:13 -07:00
|
|
|
|
2024-07-16 17:53:10 -07:00
|
|
|
local clear, command, exec, expect, feed = n.clear, n.command, n.exec, n.expect, n.feed
|
2014-12-27 14:36:58 -07:00
|
|
|
|
|
|
|
describe('signs', function()
|
2024-07-16 17:53:10 -07:00
|
|
|
before_each(clear)
|
2014-12-27 14:36:58 -07:00
|
|
|
|
2024-07-16 17:53:10 -07:00
|
|
|
it('are working', function()
|
2017-04-08 14:12:26 -07:00
|
|
|
command('sign define JumpSign text=x')
|
|
|
|
command([[exe 'sign place 42 line=2 name=JumpSign buffer=' . bufnr('')]])
|
2014-12-27 14:36:58 -07:00
|
|
|
-- Split the window to the bottom to verify :sign-jump will stay in the current
|
|
|
|
-- window if the buffer is displayed there.
|
2017-04-08 14:12:26 -07:00
|
|
|
command('bot split')
|
|
|
|
command([[exe 'sign jump 42 buffer=' . bufnr('')]])
|
|
|
|
command([[call append(line('$'), winnr())]])
|
2014-12-27 14:36:58 -07:00
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
expect([[
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2014-12-27 14:36:58 -07:00
|
|
|
2]])
|
|
|
|
end)
|
2024-07-16 17:53:10 -07:00
|
|
|
|
|
|
|
-- oldtest: Test_sign_cursor_position()
|
|
|
|
it('are drawn correctly', function()
|
|
|
|
local screen = Screen.new(75, 6)
|
2024-12-14 11:21:50 -07:00
|
|
|
screen:add_extra_attr_ids({
|
|
|
|
[100] = { foreground = Screen.colors.Blue4, background = Screen.colors.Yellow },
|
|
|
|
})
|
2024-07-16 17:53:10 -07:00
|
|
|
exec([[
|
|
|
|
call setline(1, [repeat('x', 75), 'mmmm', 'yyyy'])
|
|
|
|
call cursor(2,1)
|
|
|
|
sign define s1 texthl=Search text==>
|
2024-07-16 18:20:41 -07:00
|
|
|
sign define s2 linehl=Pmenu
|
2024-07-16 17:53:10 -07:00
|
|
|
redraw
|
|
|
|
sign place 10 line=2 name=s1
|
|
|
|
]])
|
|
|
|
screen:expect([[
|
|
|
|
{7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|
|
|
|
{7: }xx |
|
2024-12-14 11:21:50 -07:00
|
|
|
{100:=>}^mmmm |
|
2024-07-16 17:53:10 -07:00
|
|
|
{7: }yyyy |
|
|
|
|
{1:~ }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
|
|
|
-- Change the sign text
|
|
|
|
command('sign define s1 text=-)')
|
|
|
|
screen:expect([[
|
|
|
|
{7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|
|
|
|
{7: }xx |
|
2024-12-14 11:21:50 -07:00
|
|
|
{100:-)}^mmmm |
|
2024-07-16 17:53:10 -07:00
|
|
|
{7: }yyyy |
|
|
|
|
{1:~ }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
2024-07-16 18:20:41 -07:00
|
|
|
-- Also place a line HL sign
|
|
|
|
command('sign place 11 line=2 name=s2')
|
|
|
|
screen:expect([[
|
|
|
|
{7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|
|
|
|
{7: }xx |
|
2024-12-14 11:21:50 -07:00
|
|
|
{100:-)}{4:^mmmm }|
|
2024-07-16 18:20:41 -07:00
|
|
|
{7: }yyyy |
|
|
|
|
{1:~ }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
2024-07-16 17:53:10 -07:00
|
|
|
-- update cursor position calculation
|
|
|
|
feed('lh')
|
2024-07-16 18:20:41 -07:00
|
|
|
command('sign unplace 11')
|
2024-07-16 17:53:10 -07:00
|
|
|
command('sign unplace 10')
|
|
|
|
screen:expect([[
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|
|
|
|
^mmmm |
|
|
|
|
yyyy |
|
|
|
|
{1:~ }|*2
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
2014-12-27 14:36:58 -07:00
|
|
|
end)
|