2017-02-24 02:35:27 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
|
|
local Screen = require('test.functional.ui.screen')
|
2017-04-25 02:13:29 -07:00
|
|
|
local clear, command, eq = helpers.clear, helpers.command, helpers.eq
|
2017-02-24 02:35:27 -07:00
|
|
|
|
2017-10-31 02:45:06 -07:00
|
|
|
describe('ui/ext_tabline', function()
|
2017-02-24 02:35:27 -07:00
|
|
|
local screen
|
2021-06-27 12:30:09 -07:00
|
|
|
local event_tabs, event_curtab, event_curbuf, event_buffers
|
2017-02-24 02:35:27 -07:00
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
screen = Screen.new(25, 5)
|
2017-04-25 01:14:29 -07:00
|
|
|
screen:attach({rgb=true, ext_tabline=true})
|
2021-06-27 12:30:09 -07:00
|
|
|
function screen:_handle_tabline_update(curtab, tabs, curbuf, buffers)
|
|
|
|
event_curtab = curtab
|
|
|
|
event_tabs = tabs
|
|
|
|
event_curbuf = curbuf
|
|
|
|
event_buffers = buffers
|
2019-12-01 02:06:10 -07:00
|
|
|
end
|
2017-02-24 02:35:27 -07:00
|
|
|
end)
|
|
|
|
|
2017-10-31 02:45:06 -07:00
|
|
|
it('publishes UI events', function()
|
|
|
|
command("tabedit another-tab")
|
2017-04-25 02:13:29 -07:00
|
|
|
|
2017-10-31 02:45:06 -07:00
|
|
|
local expected_tabs = {
|
|
|
|
{tab = { id = 1 }, name = '[No Name]'},
|
|
|
|
{tab = { id = 2 }, name = 'another-tab'},
|
|
|
|
}
|
2018-08-20 09:51:25 -07:00
|
|
|
screen:expect{grid=[[
|
2017-10-31 02:45:06 -07:00
|
|
|
^ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
|
|
2018-08-20 09:51:25 -07:00
|
|
|
]], condition=function()
|
2017-10-31 02:45:06 -07:00
|
|
|
eq({ id = 2 }, event_curtab)
|
|
|
|
eq(expected_tabs, event_tabs)
|
2018-08-20 09:51:25 -07:00
|
|
|
end}
|
2017-02-24 02:35:27 -07:00
|
|
|
|
2017-10-31 02:45:06 -07:00
|
|
|
command("tabNext")
|
2018-08-20 09:51:25 -07:00
|
|
|
screen:expect{grid=[[
|
2017-10-31 02:45:06 -07:00
|
|
|
^ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
|
|
2018-08-20 09:51:25 -07:00
|
|
|
]], condition=function()
|
2017-10-31 02:45:06 -07:00
|
|
|
eq({ id = 1 }, event_curtab)
|
|
|
|
eq(expected_tabs, event_tabs)
|
2018-08-20 09:51:25 -07:00
|
|
|
end}
|
2017-02-24 02:35:27 -07:00
|
|
|
end)
|
2021-06-27 12:30:09 -07:00
|
|
|
|
|
|
|
it('buffer UI events', function()
|
|
|
|
local expected_buffers_initial= {
|
|
|
|
{buffer = { id = 1 }, name = '[No Name]'},
|
|
|
|
}
|
|
|
|
|
|
|
|
screen:expect{grid=[[
|
|
|
|
^ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
|
|
|
|
|
]], condition=function()
|
|
|
|
eq({ id = 1}, event_curbuf)
|
|
|
|
eq(expected_buffers_initial, event_buffers)
|
|
|
|
end}
|
|
|
|
|
|
|
|
command("badd another-buffer")
|
|
|
|
command("bnext")
|
|
|
|
|
|
|
|
local expected_buffers = {
|
2021-08-17 20:30:58 -07:00
|
|
|
{buffer = { id = 1 }, name = '[No Name]'},
|
2021-06-27 12:30:09 -07:00
|
|
|
{buffer = { id = 2 }, name = 'another-buffer'},
|
|
|
|
}
|
|
|
|
screen:expect{grid=[[
|
|
|
|
^ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
|
|
|
|
|
]], condition=function()
|
|
|
|
eq({ id = 2 }, event_curbuf)
|
|
|
|
eq(expected_buffers, event_buffers)
|
|
|
|
end}
|
|
|
|
end)
|
2017-02-24 02:35:27 -07:00
|
|
|
end)
|
2022-10-22 00:54:29 -07:00
|
|
|
|
|
|
|
describe("tabline", function()
|
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
screen = Screen.new(42, 5)
|
|
|
|
screen:attach()
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('redraws when tabline option is set', function()
|
|
|
|
command('set tabline=asdf')
|
|
|
|
command('set showtabline=2')
|
|
|
|
screen:expect{grid=[[
|
|
|
|
{1:asdf }|
|
|
|
|
^ |
|
|
|
|
{2:~ }|
|
|
|
|
{2:~ }|
|
|
|
|
|
|
|
|
|
]], attr_ids={
|
|
|
|
[1] = {reverse = true};
|
|
|
|
[2] = {bold = true, foreground = Screen.colors.Blue1};
|
|
|
|
}}
|
|
|
|
command('set tabline=jkl')
|
|
|
|
screen:expect{grid=[[
|
|
|
|
{1:jkl }|
|
|
|
|
^ |
|
|
|
|
{2:~ }|
|
|
|
|
{2:~ }|
|
|
|
|
|
|
|
|
|
]], attr_ids={
|
|
|
|
[1] = {reverse = true};
|
|
|
|
[2] = {bold = true, foreground = Screen.colors.Blue};
|
|
|
|
}}
|
|
|
|
end)
|
2023-01-16 18:51:01 -07:00
|
|
|
|
|
|
|
it('click definitions do not leak memory #21765', function()
|
|
|
|
command('set tabline=%@MyClickFunc@MyClickText%T')
|
|
|
|
command('set showtabline=2')
|
|
|
|
command('redrawtabline')
|
|
|
|
end)
|
2022-10-22 00:54:29 -07:00
|
|
|
end)
|