aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/api/vim_spec.lua10
-rw-r--r--test/functional/core/startup_spec.lua12
-rw-r--r--test/functional/legacy/scroll_opt_spec.lua43
-rw-r--r--test/functional/lua/help_spec.lua7
-rw-r--r--test/functional/plugin/lsp/inlay_hint_spec.lua10
-rw-r--r--test/functional/treesitter/parser_spec.lua29
-rw-r--r--test/functional/ui/multibyte_spec.lua16
-rw-r--r--test/functional/ui/statuscolumn_spec.lua114
-rw-r--r--test/functional/ui/statusline_spec.lua337
-rw-r--r--test/functional/ui/tabline_spec.lua73
10 files changed, 430 insertions, 221 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index d56f780ca6..1ac732b128 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -335,8 +335,7 @@ describe('API', function()
nvim('command', 'edit '..fname)
nvim('command', 'normal itesting\napi')
nvim('command', 'w')
- local f = io.open(fname)
- ok(f ~= nil)
+ local f = assert(io.open(fname))
if is_os('win') then
eq('testing\r\napi\r\n', f:read('*a'))
else
@@ -3950,7 +3949,7 @@ describe('API', function()
}
}, meths.parse_cmd('MyCommand test it', {}))
end)
- it('errors for invalid command', function()
+ it('validates command', function()
eq('Error while parsing command line', pcall_err(meths.parse_cmd, '', {}))
eq('Error while parsing command line', pcall_err(meths.parse_cmd, '" foo', {}))
eq('Error while parsing command line: E492: Not an editor command: Fubar',
@@ -4097,6 +4096,11 @@ describe('API', function()
eq("Invalid 'reg': expected single character, got xx",
pcall_err(meths.cmd, { cmd = "put", args = {}, reg = 'xx' }, {}))
+ -- #20681
+ eq('Invalid command: "win_getid"', pcall_err(meths.cmd, { cmd = 'win_getid'}, {}))
+ eq('Invalid command: "echo "hi""', pcall_err(meths.cmd, { cmd = 'echo "hi"'}, {}))
+ eq('Invalid command: "win_getid"', pcall_err(exec_lua, [[return vim.cmd.win_getid{}]]))
+
-- Lua call allows empty {} for dict item.
eq('', exec_lua([[return vim.cmd{ cmd = "set", args = {}, magic = {} }]]))
eq('', exec_lua([[return vim.cmd{ cmd = "set", args = {}, mods = {} }]]))
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index 58bf7f8681..ef3c2eadd9 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -144,6 +144,18 @@ describe('startup', function()
end)
it('sets _G.arg', function()
+ -- nvim -l foo.lua
+ assert_l_out([[
+ bufs:
+ nvim args: 3
+ lua args: {
+ [0] = "test/functional/fixtures/startup.lua"
+ }]],
+ {},
+ {}
+ )
+ eq(0, eval('v:shell_error'))
+
-- nvim -l foo.lua [args]
assert_l_out([[
bufs:
diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua
index 3b755ff3e8..ae6a409762 100644
--- a/test/functional/legacy/scroll_opt_spec.lua
+++ b/test/functional/legacy/scroll_opt_spec.lua
@@ -939,6 +939,49 @@ describe('smoothscroll', function()
]])
end)
+ -- oldtest: Test_smoothscroll_zero_width_scroll_cursor_bot()
+ it('does not divide by zero in zero-width window', function()
+ screen:try_resize(40, 19)
+ screen:set_default_attr_ids({
+ [1] = {foreground = Screen.colors.Brown}; -- LineNr
+ [2] = {bold = true, foreground = Screen.colors.Blue}; -- NonText
+ [3] = {bold = true, reverse = true}; -- StatusLine
+ [4] = {reverse = true}; -- StatusLineNC
+ })
+ exec([[
+ silent normal yy
+ silent normal 19p
+ set cpoptions+=n
+ vsplit
+ vertical resize 0
+ set foldcolumn=1
+ set number
+ set smoothscroll
+ silent normal 20G
+ ]])
+ screen:expect([[
+ {1: }│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:@}│ |
+ {2:^@}│ |
+ {3:< }{4:[No Name] [+] }|
+ |
+ ]])
+ end)
+
it("works with virt_lines above and below", function()
screen:try_resize(55, 7)
exec([=[
diff --git a/test/functional/lua/help_spec.lua b/test/functional/lua/help_spec.lua
index cdc7761e48..8d843cd208 100644
--- a/test/functional/lua/help_spec.lua
+++ b/test/functional/lua/help_spec.lua
@@ -19,11 +19,12 @@ describe(':help docs', function()
local rv = exec_lua([[return require('scripts.gen_help_html').validate('./build/runtime/doc')]])
-- Check that we actually found helpfiles.
ok(rv.helpfiles > 100, '>100 :help files', rv.helpfiles)
+
+ eq({}, rv.parse_errors, 'no parse errors')
+ eq(0, rv.err_count, 'no parse errors')
eq({}, rv.invalid_links, 'invalid tags in :help docs')
eq({}, rv.invalid_urls, 'invalid URLs in :help docs')
- eq({}, rv.invalid_spelling, 'invalid spelling in :help docs')
- -- Check that parse errors did not increase.
- ok(rv.err_count == 0, 'no parse errors', rv.err_count)
+ eq({}, rv.invalid_spelling, 'invalid spelling in :help docs (see spell_dict in scripts/gen_help_html.lua)')
end)
it('gen_help_html.lua generates HTML', function()
diff --git a/test/functional/plugin/lsp/inlay_hint_spec.lua b/test/functional/plugin/lsp/inlay_hint_spec.lua
index 574a4fa5a0..b19f2ba146 100644
--- a/test/functional/plugin/lsp/inlay_hint_spec.lua
+++ b/test/functional/plugin/lsp/inlay_hint_spec.lua
@@ -64,7 +64,7 @@ describe('inlay hints', function()
end)
it(
- 'inlay hints are applied when vim.lsp.buf.inlay_hint(true) is called',
+ 'inlay hints are applied when vim.lsp.inlay_hint(true) is called',
function()
local res = exec_lua([[
bufnr = vim.api.nvim_get_current_buf()
@@ -79,7 +79,7 @@ describe('inlay hints', function()
insert(text)
- exec_lua([[vim.lsp.buf.inlay_hint(bufnr, true)]])
+ exec_lua([[vim.lsp.inlay_hint(bufnr, true)]])
screen:expect({
grid = [[
auto add(int a, int b)-> int { return a + b; } |
@@ -96,7 +96,7 @@ describe('inlay hints', function()
end)
it(
- 'inlay hints are cleared when vim.lsp.buf.inlay_hint(false) is called',
+ 'inlay hints are cleared when vim.lsp.inlay_hint(false) is called',
function()
exec_lua([[
bufnr = vim.api.nvim_get_current_buf()
@@ -105,7 +105,7 @@ describe('inlay hints', function()
]])
insert(text)
- exec_lua([[vim.lsp.buf.inlay_hint(bufnr, true)]])
+ exec_lua([[vim.lsp.inlay_hint(bufnr, true)]])
screen:expect({
grid = [[
auto add(int a, int b)-> int { return a + b; } |
@@ -119,7 +119,7 @@ describe('inlay hints', function()
|
]]
})
- exec_lua([[vim.lsp.buf.inlay_hint(bufnr, false)]])
+ exec_lua([[vim.lsp.inlay_hint(bufnr, false)]])
screen:expect({
grid = [[
auto add(int a, int b) { return a + b; } |
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua
index e463382d07..d2f40bfe00 100644
--- a/test/functional/treesitter/parser_spec.lua
+++ b/test/functional/treesitter/parser_spec.lua
@@ -922,12 +922,6 @@ int x = INT_MAX;
[19] = '1' }, get_fold_levels())
helpers.command('1,2d')
- helpers.poke_eventloop()
-
- exec_lua([[vim.treesitter.get_parser():parse()]])
-
- helpers.poke_eventloop()
- helpers.sleep(100)
eq({
[1] = '0',
@@ -947,6 +941,29 @@ int x = INT_MAX;
[15] = '2',
[16] = '1',
[17] = '0' }, get_fold_levels())
+
+ helpers.command('1put!')
+
+ eq({
+ [1] = '>1',
+ [2] = '1',
+ [3] = '1',
+ [4] = '1',
+ [5] = '>2',
+ [6] = '2',
+ [7] = '2',
+ [8] = '1',
+ [9] = '1',
+ [10] = '>2',
+ [11] = '2',
+ [12] = '2',
+ [13] = '2',
+ [14] = '2',
+ [15] = '>3',
+ [16] = '3',
+ [17] = '3',
+ [18] = '2',
+ [19] = '1' }, get_fold_levels())
end)
it('tracks the root range properly (#22911)', function()
diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua
index 9f413f8bff..5cecd423d7 100644
--- a/test/functional/ui/multibyte_spec.lua
+++ b/test/functional/ui/multibyte_spec.lua
@@ -17,10 +17,11 @@ describe("multibyte rendering", function()
screen = Screen.new(60, 6)
screen:attach({rgb=true})
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
+ [1] = {bold = true, foreground = Screen.colors.Blue},
[2] = {background = Screen.colors.WebGray},
[3] = {background = Screen.colors.LightMagenta},
[4] = {bold = true},
+ [5] = {foreground = Screen.colors.Blue},
})
end)
@@ -119,6 +120,19 @@ describe("multibyte rendering", function()
]])
end)
+ it('0xffff is shown as 4 hex digits', function()
+ command([[call setline(1, "\uFFFF!!!")]])
+ feed('$')
+ screen:expect{grid=[[
+ {5:<ffff>}!!^! |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ end)
+
it('works with a lot of unicode (zalgo) text', function()
screen:try_resize(65, 10)
meths.buf_set_lines(0,0,-1,true, split(dedent [[
diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua
index 6624fb008d..d713580ca9 100644
--- a/test/functional/ui/statuscolumn_spec.lua
+++ b/test/functional/ui/statuscolumn_spec.lua
@@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
+local exec = helpers.exec
local eval = helpers.eval
local exec_lua = helpers.exec_lua
local feed = helpers.feed
@@ -440,44 +441,81 @@ describe('statuscolumn', function()
end)
for _, model in ipairs(mousemodels) do
- it("works with 'statuscolumn' clicks with mousemodel=" .. model, function()
- command('set mousemodel=' .. model)
- command([[
- function! MyClickFunc(minwid, clicks, button, mods)
- let g:testvar = printf("%d %d %s %d", a:minwid, a:clicks, a:button, getmousepos().line)
- if a:mods !=# ' '
- let g:testvar ..= '(' .. a:mods .. ')'
- endif
- endfunction
- set stc=%0@MyClickFunc@%=%l%T
- ]])
- meths.input_mouse('left', 'press', '', 0, 0, 0)
- eq('0 1 l 4', eval("g:testvar"))
- meths.input_mouse('left', 'press', '', 0, 0, 0)
- eq('0 2 l 4', eval("g:testvar"))
- meths.input_mouse('left', 'press', '', 0, 0, 0)
- eq('0 3 l 4', eval("g:testvar"))
- meths.input_mouse('left', 'press', '', 0, 0, 0)
- eq('0 4 l 4', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 3, 0)
- eq('0 1 r 7', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 3, 0)
- eq('0 2 r 7', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 3, 0)
- eq('0 3 r 7', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 3, 0)
- eq('0 4 r 7', eval("g:testvar"))
- command('set laststatus=2 winbar=%f')
- command('let g:testvar=""')
- -- Check that winbar click doesn't register as statuscolumn click
- meths.input_mouse('right', 'press', '', 0, 0, 0)
- eq('', eval("g:testvar"))
- -- Check that statusline click doesn't register as statuscolumn click
- meths.input_mouse('right', 'press', '', 0, 12, 0)
- eq('', eval("g:testvar"))
- -- Check that cmdline click doesn't register as statuscolumn click
- meths.input_mouse('right', 'press', '', 0, 13, 0)
- eq('', eval("g:testvar"))
+ describe('with mousemodel=' .. model, function()
+ before_each(function()
+ command('set mousemodel=' .. model)
+ exec([[
+ function! MyClickFunc(minwid, clicks, button, mods)
+ let g:testvar = printf("%d %d %s %d", a:minwid, a:clicks, a:button, getmousepos().line)
+ if a:mods !=# ' '
+ let g:testvar ..= '(' .. a:mods .. ')'
+ endif
+ endfunction
+ let g:testvar = ''
+ ]])
+ end)
+
+ it('clicks work with mousemodel=' .. model, function()
+ meths.set_option_value('statuscolumn', '%0@MyClickFunc@%=%l%T', {})
+ meths.input_mouse('left', 'press', '', 0, 0, 0)
+ eq('0 1 l 4', eval("g:testvar"))
+ meths.input_mouse('left', 'press', '', 0, 0, 0)
+ eq('0 2 l 4', eval("g:testvar"))
+ meths.input_mouse('left', 'press', '', 0, 0, 0)
+ eq('0 3 l 4', eval("g:testvar"))
+ meths.input_mouse('left', 'press', '', 0, 0, 0)
+ eq('0 4 l 4', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 3, 0)
+ eq('0 1 r 7', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 3, 0)
+ eq('0 2 r 7', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 3, 0)
+ eq('0 3 r 7', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 3, 0)
+ eq('0 4 r 7', eval("g:testvar"))
+ command('set laststatus=2 winbar=%f')
+ command('let g:testvar = ""')
+ -- Check that winbar click doesn't register as statuscolumn click
+ meths.input_mouse('right', 'press', '', 0, 0, 0)
+ eq('', eval("g:testvar"))
+ -- Check that statusline click doesn't register as statuscolumn click
+ meths.input_mouse('right', 'press', '', 0, 12, 0)
+ eq('', eval("g:testvar"))
+ -- Check that cmdline click doesn't register as statuscolumn click
+ meths.input_mouse('right', 'press', '', 0, 13, 0)
+ eq('', eval("g:testvar"))
+ end)
+
+ it('clicks and highlights work with control characters', function()
+ meths.set_option_value('statuscolumn', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {})
+ screen:expect{grid=[[
+ {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |
+ {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |
+ {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |
+ {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |
+ {1:^I}{0:^A^I^A^I}{1:^A}^aaaaa |
+ {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |
+ {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |
+ {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |
+ {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |
+ {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |
+ {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |
+ {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |
+ {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |
+ |
+ ]], attr_ids={
+ [0] = {foreground = Screen.colors.Blue, bold = true}; -- NonText
+ [1] = {foreground = Screen.colors.Brown}; -- LineNr
+ }}
+ meths.input_mouse('right', 'press', '', 0, 4, 3)
+ eq('', eval("g:testvar"))
+ meths.input_mouse('left', 'press', '', 0, 5, 8)
+ eq('', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 6, 4)
+ eq('0 1 r 10', eval("g:testvar"))
+ meths.input_mouse('left', 'press', '', 0, 7, 7)
+ eq('0 1 l 11', eval("g:testvar"))
+ end)
end)
end
diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua
index c47b26f55e..7967fb6865 100644
--- a/test/functional/ui/statusline_spec.lua
+++ b/test/functional/ui/statusline_spec.lua
@@ -21,6 +21,10 @@ for _, model in ipairs(mousemodels) do
before_each(function()
clear()
screen = Screen.new(40, 8)
+ screen:set_default_attr_ids({
+ [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText
+ [1] = {bold = true, reverse = true}; -- StatusLine
+ })
screen:attach()
command('set laststatus=2 mousemodel=' .. model)
exec([=[
@@ -30,163 +34,190 @@ for _, model in ipairs(mousemodels) do
let g:testvar ..= '(' .. a:mods .. ')'
endif
endfunction
+ let g:testvar = ''
]=])
- end)
-
- it('works', function()
- meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
- meths.input_mouse('left', 'press', '', 0, 6, 17)
- eq('0 1 l', eval("g:testvar"))
- meths.input_mouse('left', 'press', '', 0, 6, 17)
- eq('0 2 l', eval("g:testvar"))
- meths.input_mouse('left', 'press', '', 0, 6, 17)
- eq('0 3 l', eval("g:testvar"))
- meths.input_mouse('left', 'press', '', 0, 6, 17)
- eq('0 4 l', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 6, 17)
- eq('0 1 r', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 6, 17)
- eq('0 2 r', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 6, 17)
- eq('0 3 r', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 6, 17)
- eq('0 4 r', eval("g:testvar"))
- end)
-
- it('works for winbar', function()
- meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
- meths.input_mouse('left', 'press', '', 0, 0, 17)
- eq('0 1 l', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 0, 17)
- eq('0 1 r', eval("g:testvar"))
- end)
-
- it('works for winbar in floating window', function()
- meths.open_win(0, true, { width=30, height=4, relative='editor', row=1, col=5,
- border = "single" })
- meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T',
- { scope = 'local' })
- meths.input_mouse('left', 'press', '', 0, 2, 23)
- eq('0 1 l', eval("g:testvar"))
- end)
-
- it('works when there are multiple windows', function()
- command('split')
- meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
- meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
- meths.input_mouse('left', 'press', '', 0, 0, 17)
- eq('0 1 l', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 4, 17)
- eq('0 1 r', eval("g:testvar"))
- meths.input_mouse('middle', 'press', '', 0, 3, 17)
- eq('0 1 m', eval("g:testvar"))
- meths.input_mouse('left', 'press', '', 0, 6, 17)
- eq('0 1 l', eval("g:testvar"))
- end)
-
- it('works with Lua function', function()
- exec_lua([[
- function clicky_func(minwid, clicks, button, mods)
- vim.g.testvar = string.format("%d %d %s", minwid, clicks, button)
- end
- ]])
- meths.set_option_value('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T', {})
- meths.input_mouse('left', 'press', '', 0, 6, 17)
- eq('0 1 l', eval("g:testvar"))
- end)
-
- it('ignores unsupported click items', function()
- command('tabnew | tabprevious')
- meths.set_option_value('statusline', '%2TNot clicky stuff%T', {})
- meths.input_mouse('left', 'press', '', 0, 6, 0)
- eq(1, meths.get_current_tabpage().id)
- meths.set_option_value('statusline', '%2XNot clicky stuff%X', {})
- meths.input_mouse('left', 'press', '', 0, 6, 0)
- eq(2, #meths.list_tabpages())
- end)
-
- it("right click works when statusline isn't focused #18994", function()
- meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
- meths.input_mouse('right', 'press', '', 0, 6, 17)
- eq('0 1 r', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 6, 17)
- eq('0 2 r', eval("g:testvar"))
- end)
-
- it("works with modifiers #18994", function()
- meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
- -- Note: alternate between left and right mouse buttons to avoid triggering multiclicks
- meths.input_mouse('left', 'press', 'S', 0, 6, 17)
- eq('0 1 l(s )', eval("g:testvar"))
- meths.input_mouse('right', 'press', 'S', 0, 6, 17)
- eq('0 1 r(s )', eval("g:testvar"))
- meths.input_mouse('left', 'press', 'A', 0, 6, 17)
- eq('0 1 l( a )', eval("g:testvar"))
- meths.input_mouse('right', 'press', 'A', 0, 6, 17)
- eq('0 1 r( a )', eval("g:testvar"))
- meths.input_mouse('left', 'press', 'AS', 0, 6, 17)
- eq('0 1 l(s a )', eval("g:testvar"))
- meths.input_mouse('right', 'press', 'AS', 0, 6, 17)
- eq('0 1 r(s a )', eval("g:testvar"))
- meths.input_mouse('left', 'press', 'T', 0, 6, 17)
- eq('0 1 l( m)', eval("g:testvar"))
- meths.input_mouse('right', 'press', 'T', 0, 6, 17)
- eq('0 1 r( m)', eval("g:testvar"))
- meths.input_mouse('left', 'press', 'TS', 0, 6, 17)
- eq('0 1 l(s m)', eval("g:testvar"))
- meths.input_mouse('right', 'press', 'TS', 0, 6, 17)
- eq('0 1 r(s m)', eval("g:testvar"))
- meths.input_mouse('left', 'press', 'C', 0, 6, 17)
- eq('0 1 l( c )', eval("g:testvar"))
- -- <C-RightMouse> is for tag jump
- end)
-
- it("works for global statusline with vertical splits #19186", function()
- command('set laststatus=3')
- meths.set_option_value('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T', {})
- command('vsplit')
- screen:expect([[
+ end)
+
+ it('works', function()
+ meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ meths.input_mouse('left', 'press', '', 0, 6, 16)
+ eq('', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 6, 29)
+ eq('', eval("g:testvar"))
+ meths.input_mouse('left', 'press', '', 0, 6, 17)
+ eq('0 1 l', eval("g:testvar"))
+ meths.input_mouse('left', 'press', '', 0, 6, 17)
+ eq('0 2 l', eval("g:testvar"))
+ meths.input_mouse('left', 'press', '', 0, 6, 17)
+ eq('0 3 l', eval("g:testvar"))
+ meths.input_mouse('left', 'press', '', 0, 6, 17)
+ eq('0 4 l', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 6, 28)
+ eq('0 1 r', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 6, 28)
+ eq('0 2 r', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 6, 28)
+ eq('0 3 r', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 6, 28)
+ eq('0 4 r', eval("g:testvar"))
+ end)
+
+ it('works with control characters and highlight', function()
+ meths.set_option_value('statusline', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {})
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {1:^I}{0:^A^I^A^I}{1:^A }|
+ |
+ ]]}
+ meths.input_mouse('right', 'press', '', 0, 6, 3)
+ eq('', eval("g:testvar"))
+ meths.input_mouse('left', 'press', '', 0, 6, 8)
+ eq('', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 6, 4)
+ eq('0 1 r', eval("g:testvar"))
+ meths.input_mouse('left', 'press', '', 0, 6, 7)
+ eq('0 1 l', eval("g:testvar"))
+ end)
+
+ it('works for winbar', function()
+ meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ meths.input_mouse('left', 'press', '', 0, 0, 17)
+ eq('0 1 l', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 0, 17)
+ eq('0 1 r', eval("g:testvar"))
+ end)
+
+ it('works for winbar in floating window', function()
+ meths.open_win(0, true, { width=30, height=4, relative='editor', row=1, col=5,
+ border = "single" })
+ meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T',
+ { scope = 'local' })
+ meths.input_mouse('left', 'press', '', 0, 2, 23)
+ eq('0 1 l', eval("g:testvar"))
+ end)
+
+ it('works when there are multiple windows', function()
+ command('split')
+ meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ meths.input_mouse('left', 'press', '', 0, 0, 17)
+ eq('0 1 l', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 4, 17)
+ eq('0 1 r', eval("g:testvar"))
+ meths.input_mouse('middle', 'press', '', 0, 3, 17)
+ eq('0 1 m', eval("g:testvar"))
+ meths.input_mouse('left', 'press', '', 0, 6, 17)
+ eq('0 1 l', eval("g:testvar"))
+ end)
+
+ it('works with Lua function', function()
+ exec_lua([[
+ function clicky_func(minwid, clicks, button, mods)
+ vim.g.testvar = string.format("%d %d %s", minwid, clicks, button)
+ end
+ ]])
+ meths.set_option_value('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T', {})
+ meths.input_mouse('left', 'press', '', 0, 6, 17)
+ eq('0 1 l', eval("g:testvar"))
+ end)
+
+ it('ignores unsupported click items', function()
+ command('tabnew | tabprevious')
+ meths.set_option_value('statusline', '%2TNot clicky stuff%T', {})
+ meths.input_mouse('left', 'press', '', 0, 6, 0)
+ eq(1, meths.get_current_tabpage().id)
+ meths.set_option_value('statusline', '%2XNot clicky stuff%X', {})
+ meths.input_mouse('left', 'press', '', 0, 6, 0)
+ eq(2, #meths.list_tabpages())
+ end)
+
+ it("right click works when statusline isn't focused #18994", function()
+ meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ meths.input_mouse('right', 'press', '', 0, 6, 17)
+ eq('0 1 r', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 6, 17)
+ eq('0 2 r', eval("g:testvar"))
+ end)
+
+ it("works with modifiers #18994", function()
+ meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
+ -- Note: alternate between left and right mouse buttons to avoid triggering multiclicks
+ meths.input_mouse('left', 'press', 'S', 0, 6, 17)
+ eq('0 1 l(s )', eval("g:testvar"))
+ meths.input_mouse('right', 'press', 'S', 0, 6, 17)
+ eq('0 1 r(s )', eval("g:testvar"))
+ meths.input_mouse('left', 'press', 'A', 0, 6, 17)
+ eq('0 1 l( a )', eval("g:testvar"))
+ meths.input_mouse('right', 'press', 'A', 0, 6, 17)
+ eq('0 1 r( a )', eval("g:testvar"))
+ meths.input_mouse('left', 'press', 'AS', 0, 6, 17)
+ eq('0 1 l(s a )', eval("g:testvar"))
+ meths.input_mouse('right', 'press', 'AS', 0, 6, 17)
+ eq('0 1 r(s a )', eval("g:testvar"))
+ meths.input_mouse('left', 'press', 'T', 0, 6, 17)
+ eq('0 1 l( m)', eval("g:testvar"))
+ meths.input_mouse('right', 'press', 'T', 0, 6, 17)
+ eq('0 1 r( m)', eval("g:testvar"))
+ meths.input_mouse('left', 'press', 'TS', 0, 6, 17)
+ eq('0 1 l(s m)', eval("g:testvar"))
+ meths.input_mouse('right', 'press', 'TS', 0, 6, 17)
+ eq('0 1 r(s m)', eval("g:testvar"))
+ meths.input_mouse('left', 'press', 'C', 0, 6, 17)
+ eq('0 1 l( c )', eval("g:testvar"))
+ -- <C-RightMouse> is for tag jump
+ end)
+
+ it("works for global statusline with vertical splits #19186", function()
+ command('set laststatus=3')
+ meths.set_option_value('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T', {})
+ command('vsplit')
+ screen:expect{grid=[[
^ │ |
- ~ │~ |
- ~ │~ |
- ~ │~ |
- ~ │~ |
- ~ │~ |
- Clicky stuff Clicky stuff|
+ {0:~ }│{0:~ }|
+ {0:~ }│{0:~ }|
+ {0:~ }│{0:~ }|
+ {0:~ }│{0:~ }|
+ {0:~ }│{0:~ }|
+ {1:Clicky stuff Clicky stuff}|
|
- ]])
-
- -- clickable area on the right
- meths.input_mouse('left', 'press', '', 0, 6, 35)
- eq('0 1 l', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 6, 35)
- eq('0 1 r', eval("g:testvar"))
-
- -- clickable area on the left
- meths.input_mouse('left', 'press', '', 0, 6, 5)
- eq('0 1 l', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 6, 5)
- eq('0 1 r', eval("g:testvar"))
- end)
-
- it('no memory leak with zero-width click labels', function()
- command([[
- let &stl = '%@Test@%T%@MyClickFunc@%=%T%@Test@'
- ]])
- meths.input_mouse('left', 'press', '', 0, 6, 0)
- eq('0 1 l', eval("g:testvar"))
- meths.input_mouse('right', 'press', '', 0, 6, 39)
- eq('0 1 r', eval("g:testvar"))
- end)
-
- it('no memory leak with truncated click labels', function()
- command([[
- let &stl = '%@MyClickFunc@foo%X' .. repeat('a', 40) .. '%<t%@Test@bar%X%@Test@baz'
- ]])
- meths.input_mouse('left', 'press', '', 0, 6, 2)
- eq('0 1 l', eval("g:testvar"))
- end)
+ ]]}
+
+ -- clickable area on the right
+ meths.input_mouse('left', 'press', '', 0, 6, 35)
+ eq('0 1 l', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 6, 35)
+ eq('0 1 r', eval("g:testvar"))
+
+ -- clickable area on the left
+ meths.input_mouse('left', 'press', '', 0, 6, 5)
+ eq('0 1 l', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 6, 5)
+ eq('0 1 r', eval("g:testvar"))
+ end)
+
+ it('no memory leak with zero-width click labels', function()
+ command([[
+ let &stl = '%@Test@%T%@MyClickFunc@%=%T%@Test@'
+ ]])
+ meths.input_mouse('left', 'press', '', 0, 6, 0)
+ eq('0 1 l', eval("g:testvar"))
+ meths.input_mouse('right', 'press', '', 0, 6, 39)
+ eq('0 1 r', eval("g:testvar"))
end)
+
+ it('no memory leak with truncated click labels', function()
+ command([[
+ let &stl = '%@MyClickFunc@foo%X' .. repeat('a', 40) .. '%<t%@Test@bar%X%@Test@baz'
+ ]])
+ meths.input_mouse('left', 'press', '', 0, 6, 2)
+ eq('0 1 l', eval("g:testvar"))
+ end)
+ end)
end
describe('global statusline', function()
diff --git a/test/functional/ui/tabline_spec.lua b/test/functional/ui/tabline_spec.lua
index 2cdec62d01..befdb7c5d1 100644
--- a/test/functional/ui/tabline_spec.lua
+++ b/test/functional/ui/tabline_spec.lua
@@ -1,6 +1,9 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, command, eq = helpers.clear, helpers.command, helpers.eq
+local insert = helpers.insert
+local meths = helpers.meths
+local assert_alive = helpers.assert_alive
describe('ui/ext_tabline', function()
local screen
@@ -92,6 +95,10 @@ describe("tabline", function()
clear()
screen = Screen.new(42, 5)
screen:attach()
+ screen:set_default_attr_ids({
+ [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText
+ [1] = {reverse = true}; -- TabLineFill
+ })
end)
it('redraws when tabline option is set', function()
@@ -100,24 +107,18 @@ describe("tabline", function()
screen:expect{grid=[[
{1:asdf }|
^ |
- {2:~ }|
- {2:~ }|
+ {0:~ }|
+ {0:~ }|
|
- ]], attr_ids={
- [1] = {reverse = true};
- [2] = {bold = true, foreground = Screen.colors.Blue1};
- }}
+ ]]}
command('set tabline=jkl')
screen:expect{grid=[[
{1:jkl }|
^ |
- {2:~ }|
- {2:~ }|
+ {0:~ }|
+ {0:~ }|
|
- ]], attr_ids={
- [1] = {reverse = true};
- [2] = {bold = true, foreground = Screen.colors.Blue};
- }}
+ ]]}
end)
it('click definitions do not leak memory #21765', function()
@@ -125,4 +126,52 @@ describe("tabline", function()
command('set showtabline=2')
command('redrawtabline')
end)
+
+ it('clicks work with truncated double-width label #24187', function()
+ insert('tab1')
+ command('tabnew')
+ insert('tab2')
+ command('tabprev')
+ meths.set_option_value('tabline', '%1T口口%2Ta' .. ('b'):rep(38) .. '%999Xc', {})
+ screen:expect{grid=[[
+ {1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
+ tab^1 |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]]}
+ assert_alive()
+ meths.input_mouse('left', 'press', '', 0, 0, 1)
+ screen:expect{grid=[[
+ {1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
+ tab^2 |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]]}
+ meths.input_mouse('left', 'press', '', 0, 0, 0)
+ screen:expect{grid=[[
+ {1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
+ tab^1 |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]]}
+ meths.input_mouse('left', 'press', '', 0, 0, 39)
+ screen:expect{grid=[[
+ {1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }|
+ tab^2 |
+ {0:~ }|
+ {0:~ }|
+ |
+ ]]}
+ meths.input_mouse('left', 'press', '', 0, 0, 40)
+ screen:expect{grid=[[
+ tab^1 |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]]}
+ end)
end)