aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/winbar_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/ui/winbar_spec.lua')
-rw-r--r--test/functional/ui/winbar_spec.lua406
1 files changed, 146 insertions, 260 deletions
diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua
index 78bbcd3a63..c2a52c0f21 100644
--- a/test/functional/ui/winbar_spec.lua
+++ b/test/functional/ui/winbar_spec.lua
@@ -3,12 +3,11 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local command = helpers.command
local insert = helpers.insert
-local meths = helpers.meths
+local api = helpers.api
local eq = helpers.eq
local poke_eventloop = helpers.poke_eventloop
local feed = helpers.feed
-local funcs = helpers.funcs
-local curwin = helpers.curwin
+local fn = helpers.fn
local pcall_err = helpers.pcall_err
describe('winbar', function()
@@ -19,59 +18,50 @@ describe('winbar', function()
screen = Screen.new(60, 13)
screen:attach()
screen:set_default_attr_ids({
- [1] = {bold = true},
- [2] = {reverse = true},
- [3] = {bold = true, foreground = Screen.colors.Blue},
- [4] = {bold = true, reverse = true},
- [5] = {bold = true, foreground = Screen.colors.Red},
- [6] = {foreground = Screen.colors.Blue},
- [7] = {background = Screen.colors.LightGrey},
- [8] = {background = Screen.colors.LightMagenta},
- [9] = {bold = true, foreground = Screen.colors.Blue, background = Screen.colors.LightMagenta},
- [10] = {background = Screen.colors.LightGrey, underline = true},
- [11] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Magenta},
+ [1] = { bold = true },
+ [2] = { reverse = true },
+ [3] = { bold = true, foreground = Screen.colors.Blue },
+ [4] = { bold = true, reverse = true },
+ [5] = { bold = true, foreground = Screen.colors.Red },
+ [6] = { foreground = Screen.colors.Blue },
+ [7] = { foreground = Screen.colors.Black, background = Screen.colors.LightGrey },
+ [8] = { background = Screen.colors.LightMagenta },
+ [9] = {
+ bold = true,
+ foreground = Screen.colors.Blue,
+ background = Screen.colors.LightMagenta,
+ },
+ [10] = { background = Screen.colors.LightGrey, underline = true },
+ [11] = {
+ background = Screen.colors.LightGrey,
+ underline = true,
+ bold = true,
+ foreground = Screen.colors.Magenta,
+ },
})
- meths.set_option_value('winbar', 'Set Up The Bars', {})
+ api.nvim_set_option_value('winbar', 'Set Up The Bars', {})
end)
it('works', function()
screen:expect([[
{1:Set Up The Bars }|
^ |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*10
|
]])
-- winbar is excluded from the heights returned by winheight() and getwininfo()
- eq(11, funcs.winheight(0))
- local win_info = funcs.getwininfo(curwin().id)[1]
+ eq(11, fn.winheight(0))
+ local win_info = fn.getwininfo(api.nvim_get_current_win())[1]
eq(11, win_info.height)
eq(1, win_info.winbar)
end)
- it('works with custom \'fillchars\' value', function()
+ it("works with custom 'fillchars' value", function()
command('set fillchars=wbr:+')
screen:expect([[
{1:Set Up The Bars+++++++++++++++++++++++++++++++++++++++++++++}|
^ |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*10
|
]])
end)
@@ -81,16 +71,7 @@ describe('winbar', function()
screen:expect([[
{5:Set Up The Bars }|
^ |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*10
|
]])
end)
@@ -151,20 +132,17 @@ describe('winbar', function()
]])
end)
- it('works when switching value of \'winbar\'', function()
+ it("works when switching value of 'winbar'", function()
command('belowright vsplit | split | split | set winbar=')
screen:expect([[
│^ |
- {3:~ }│{3:~ }|
- {3:~ }│{3:~ }|
+ {3:~ }│{3:~ }|*2
{3:~ }│{4:[No Name] }|
{3:~ }│ |
- {3:~ }│{3:~ }|
- {3:~ }│{3:~ }|
+ {3:~ }│{3:~ }|*2
{3:~ }│{2:[No Name] }|
{3:~ }│ |
- {3:~ }│{3:~ }|
- {3:~ }│{3:~ }|
+ {3:~ }│{3:~ }|*2
{2:[No Name] [No Name] }|
|
]])
@@ -206,54 +184,36 @@ describe('winbar', function()
insert [[
just some
random text]]
- meths.set_option_value('winbar', 'Hello, I am a ruler: %l,%c', {})
- screen:expect{grid=[[
+ api.nvim_set_option_value('winbar', 'Hello, I am a ruler: %l,%c', {})
+ screen:expect {
+ grid = [[
{1:Hello, I am a ruler: 2,11 }|
just some |
random tex^t |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*9
|
- ]]}
+ ]],
+ }
feed 'b'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:Hello, I am a ruler: 2,8 }|
just some |
random ^text |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*9
|
- ]]}
+ ]],
+ }
feed 'k'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:Hello, I am a ruler: 1,8 }|
just so^me |
random text |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*9
|
- ]]}
+ ]],
+ }
end)
it('works with laststatus=3', function()
@@ -261,15 +221,7 @@ describe('winbar', function()
screen:expect([[
{1:Set Up The Bars }|
^ |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*9
{4:[No Name] }|
|
]])
@@ -295,14 +247,7 @@ describe('winbar', function()
{10: }{11:4}{10: [No Name] }{1: [No Name] }{2: }{10:X}|
{1:Set Up The Bars }|
^ |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*8
{4:[No Name] }|
|
]])
@@ -319,7 +264,7 @@ describe('winbar', function()
line sin(theta)
line 8]])
- meths.input_mouse('left', 'press', '', 0, 5, 1)
+ api.nvim_input_mouse('left', 'press', '', 0, 5, 1)
screen:expect([[
{1:Set Up The Bars }|
line 1 |
@@ -330,14 +275,12 @@ describe('winbar', function()
line i |
line sin(theta) |
line 8 |
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*3
|
]])
- eq({5, 1}, meths.win_get_cursor(0))
+ eq({ 5, 1 }, api.nvim_win_get_cursor(0))
- meths.input_mouse('left', 'drag', '', 0, 6, 2)
+ api.nvim_input_mouse('left', 'drag', '', 0, 6, 2)
screen:expect([[
{1:Set Up The Bars }|
line 1 |
@@ -348,14 +291,12 @@ describe('winbar', function()
{7:li}^ne i |
line sin(theta) |
line 8 |
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*3
{1:-- VISUAL --} |
]])
- eq({6, 2}, meths.win_get_cursor(0))
+ eq({ 6, 2 }, api.nvim_win_get_cursor(0))
- meths.input_mouse('left', 'drag', '', 0, 1, 2)
+ api.nvim_input_mouse('left', 'drag', '', 0, 1, 2)
screen:expect([[
{1:Set Up The Bars }|
li^n{7:e 1} |
@@ -366,16 +307,14 @@ describe('winbar', function()
line i |
line sin(theta) |
line 8 |
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*3
{1:-- VISUAL --} |
]])
- eq({1, 2}, meths.win_get_cursor(0))
+ eq({ 1, 2 }, api.nvim_win_get_cursor(0))
- meths.input_mouse('left', 'drag', '', 0, 0, 2)
+ api.nvim_input_mouse('left', 'drag', '', 0, 0, 2)
screen:expect_unchanged()
- eq({1, 2}, meths.win_get_cursor(0))
+ eq({ 1, 2 }, api.nvim_win_get_cursor(0))
end)
it('dragging statusline with mouse works correctly', function()
@@ -383,92 +322,72 @@ describe('winbar', function()
screen:expect([[
{1:Set Up The Bars }|
^ |
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*3
{4:[No Name] }|
{1:Set Up The Bars }|
|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*3
{2:[No Name] }|
|
]])
- meths.input_mouse('left', 'press', '', 1, 5, 10)
+ api.nvim_input_mouse('left', 'press', '', 1, 5, 10)
poke_eventloop()
- meths.input_mouse('left', 'drag', '', 1, 6, 10)
+ api.nvim_input_mouse('left', 'drag', '', 1, 6, 10)
screen:expect([[
{1:Set Up The Bars }|
^ |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*4
{4:[No Name] }|
{1:Set Up The Bars }|
|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*2
{2:[No Name] }|
|
]])
- meths.input_mouse('left', 'drag', '', 1, 4, 10)
+ api.nvim_input_mouse('left', 'drag', '', 1, 4, 10)
screen:expect([[
{1:Set Up The Bars }|
^ |
- {3:~ }|
- {3:~ }|
+ {3:~ }|*2
{4:[No Name] }|
{1:Set Up The Bars }|
|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*4
{2:[No Name] }|
|
]])
- meths.input_mouse('left', 'press', '', 1, 11, 10)
+ api.nvim_input_mouse('left', 'press', '', 1, 11, 10)
poke_eventloop()
- meths.input_mouse('left', 'drag', '', 1, 9, 10)
+ api.nvim_input_mouse('left', 'drag', '', 1, 9, 10)
screen:expect([[
{1:Set Up The Bars }|
^ |
- {3:~ }|
- {3:~ }|
+ {3:~ }|*2
{4:[No Name] }|
{1:Set Up The Bars }|
|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*2
{2:[No Name] }|
- |
- |
- |
+ |*3
]])
- eq(3, meths.get_option_value('cmdheight', {}))
+ eq(3, api.nvim_get_option_value('cmdheight', {}))
- meths.input_mouse('left', 'drag', '', 1, 11, 10)
+ api.nvim_input_mouse('left', 'drag', '', 1, 11, 10)
screen:expect([[
{1:Set Up The Bars }|
^ |
- {3:~ }|
- {3:~ }|
+ {3:~ }|*2
{4:[No Name] }|
{1:Set Up The Bars }|
|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*4
{2:[No Name] }|
|
]])
- eq(1, meths.get_option_value('cmdheight', {}))
+ eq(1, api.nvim_get_option_value('cmdheight', {}))
end)
it('properly equalizes window height for window-local value', function()
@@ -493,40 +412,34 @@ describe('winbar', function()
end)
it('requires window-local value for floating windows', function()
- local win = meths.open_win(0, false, { relative = 'editor', row = 2, col = 10, height = 7,
- width = 30 })
- meths.set_option_value('winbar', 'bar', {})
- screen:expect{grid=[[
+ local win = api.nvim_open_win(
+ 0,
+ false,
+ { relative = 'editor', row = 2, col = 10, height = 7, width = 30 }
+ )
+ api.nvim_set_option_value('winbar', 'bar', {})
+ screen:expect {
+ grid = [[
{1:bar }|
^ |
{3:~ }{8: }{3: }|
- {3:~ }{9:~ }{3: }|
- {3:~ }{9:~ }{3: }|
- {3:~ }{9:~ }{3: }|
- {3:~ }{9:~ }{3: }|
- {3:~ }{9:~ }{3: }|
- {3:~ }{9:~ }{3: }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- |
- ]]}
- meths.set_option_value('winbar', 'floaty bar', { scope = 'local', win = win.id })
- screen:expect{grid=[[
+ {3:~ }{9:~ }{3: }|*6
+ {3:~ }|*3
+ |
+ ]],
+ }
+ api.nvim_set_option_value('winbar', 'floaty bar', { scope = 'local', win = win })
+ screen:expect {
+ grid = [[
{1:bar }|
^ |
{3:~ }{1:floaty bar }{3: }|
{3:~ }{8: }{3: }|
- {3:~ }{9:~ }{3: }|
- {3:~ }{9:~ }{3: }|
- {3:~ }{9:~ }{3: }|
- {3:~ }{9:~ }{3: }|
- {3:~ }{9:~ }{3: }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }{9:~ }{3: }|*5
+ {3:~ }|*3
|
- ]]}
+ ]],
+ }
end)
it('works correctly when moving a split', function()
@@ -537,8 +450,7 @@ describe('winbar', function()
screen:expect([[
{1:foo }│ |
^ │{3:~ }|
- {3:~ }│{3:~ }|
- {3:~ }│{3:~ }|
+ {3:~ }│{3:~ }|*2
{4:[No Name] }{2:[No Name] }|
|
]])
@@ -547,8 +459,7 @@ describe('winbar', function()
screen:expect([[
│{1:foo }|
{3:~ }│^ |
- {3:~ }│{3:~ }|
- {3:~ }│{3:~ }|
+ {3:~ }│{3:~ }|*2
{2:[No Name] }{4:[No Name] }|
|
]])
@@ -558,8 +469,7 @@ describe('winbar', function()
screen:expect([[
{1:foo }│^ |
│{3:~ }|
- {3:~ }│{3:~ }|
- {3:~ }│{3:~ }|
+ {3:~ }│{3:~ }|*2
{2:[No Name] }{4:[No Name] }|
|
]])
@@ -571,14 +481,7 @@ describe('winbar', function()
^ |
{4:[No Name] }|
|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*8
{2:[No Name] }|
|
]])
@@ -589,12 +492,7 @@ describe('winbar', function()
{4:[No Name] }|
{1:a }|
|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*6
{2:[No Name] }|
|
]])
@@ -628,12 +526,12 @@ describe('local winbar with tabs', function()
screen = Screen.new(60, 10)
screen:attach()
screen:set_default_attr_ids({
- [1] = {bold = true},
- [2] = {reverse = true},
- [3] = {bold = true, foreground = Screen.colors.Blue},
- [4] = {underline = true, background = Screen.colors.LightGray}
+ [1] = { bold = true },
+ [2] = { reverse = true },
+ [3] = { bold = true, foreground = Screen.colors.Blue },
+ [4] = { underline = true, background = Screen.colors.LightGray },
})
- meths.set_option_value('winbar', 'foo', { scope = 'local', win = 0 })
+ api.nvim_set_option_value('winbar', 'foo', { scope = 'local', win = 0 })
end)
it('works', function()
@@ -641,28 +539,19 @@ describe('local winbar with tabs', function()
screen:expect([[
{4: [No Name] }{1: [No Name] }{2: }{4:X}|
^ |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*7
|
]])
command('tabnext')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: [No Name] }{4: [No Name] }{2: }{4:X}|
{1:foo }|
^ |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*6
|
- ]]}
+ ]],
+ }
end)
it('can edit new empty buffer #19458', function()
@@ -670,68 +559,65 @@ describe('local winbar with tabs', function()
some
goofy
text]]
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:foo }|
some |
goofy |
tex^t |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*5
|
- ]]}
+ ]],
+ }
-- this used to throw an E315 ml_get error
command 'tabedit'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{4: + [No Name] }{1: [No Name] }{2: }{4:X}|
^ |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*7
|
- ]]}
+ ]],
+ }
command 'tabprev'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: + [No Name] }{4: [No Name] }{2: }{4:X}|
{1:foo }|
some |
goofy |
tex^t |
- {3:~ }|
- {3:~ }|
- {3:~ }|
- {3:~ }|
+ {3:~ }|*4
|
- ]]}
+ ]],
+ }
end)
end)
it('winbar works properly when redrawing is postponed #23534', function()
- clear({args = {
- '-c', 'set laststatus=2 lazyredraw',
- '-c', 'setlocal statusline=(statusline) winbar=(winbar)',
- '-c', 'call nvim_input(":<Esc>")',
- }})
+ clear({
+ args = {
+ '-c',
+ 'set laststatus=2 lazyredraw',
+ '-c',
+ 'setlocal statusline=(statusline) winbar=(winbar)',
+ '-c',
+ 'call nvim_input(":<Esc>")',
+ },
+ })
local screen = Screen.new(60, 6)
screen:attach()
screen:set_default_attr_ids({
- [0] = {foreground = Screen.colors.Blue, bold = true},
- [1] = {bold = true},
- [2] = {bold = true, reverse = true},
+ [0] = { foreground = Screen.colors.Blue, bold = true },
+ [1] = { bold = true },
+ [2] = { bold = true, reverse = true },
})
screen:expect([[
{1:(winbar) }|
^ |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
{2:(statusline) }|
|
]])