mirror of
https://github.com/neovim/neovim.git
synced 2025-12-17 20:05:38 +00:00
test(statusline): add test with control characters (#24197)
This commit is contained in:
@@ -21,6 +21,10 @@ for _, model in ipairs(mousemodels) do
|
|||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
screen = Screen.new(40, 8)
|
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()
|
screen:attach()
|
||||||
command('set laststatus=2 mousemodel=' .. model)
|
command('set laststatus=2 mousemodel=' .. model)
|
||||||
exec([=[
|
exec([=[
|
||||||
@@ -30,11 +34,16 @@ for _, model in ipairs(mousemodels) do
|
|||||||
let g:testvar ..= '(' .. a:mods .. ')'
|
let g:testvar ..= '(' .. a:mods .. ')'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
let g:testvar = ''
|
||||||
]=])
|
]=])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works', function()
|
it('works', function()
|
||||||
meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
|
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)
|
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
||||||
eq('0 1 l', eval("g:testvar"))
|
eq('0 1 l', eval("g:testvar"))
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
||||||
@@ -43,16 +52,38 @@ for _, model in ipairs(mousemodels) do
|
|||||||
eq('0 3 l', eval("g:testvar"))
|
eq('0 3 l', eval("g:testvar"))
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
||||||
eq('0 4 l', eval("g:testvar"))
|
eq('0 4 l', eval("g:testvar"))
|
||||||
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
meths.input_mouse('right', 'press', '', 0, 6, 28)
|
||||||
eq('0 1 r', eval("g:testvar"))
|
eq('0 1 r', eval("g:testvar"))
|
||||||
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
meths.input_mouse('right', 'press', '', 0, 6, 28)
|
||||||
eq('0 2 r', eval("g:testvar"))
|
eq('0 2 r', eval("g:testvar"))
|
||||||
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
meths.input_mouse('right', 'press', '', 0, 6, 28)
|
||||||
eq('0 3 r', eval("g:testvar"))
|
eq('0 3 r', eval("g:testvar"))
|
||||||
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
meths.input_mouse('right', 'press', '', 0, 6, 28)
|
||||||
eq('0 4 r', eval("g:testvar"))
|
eq('0 4 r', eval("g:testvar"))
|
||||||
end)
|
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()
|
it('works for winbar', function()
|
||||||
meths.set_option_value('winbar', '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)
|
meths.input_mouse('left', 'press', '', 0, 0, 17)
|
||||||
@@ -145,16 +176,16 @@ for _, model in ipairs(mousemodels) do
|
|||||||
command('set laststatus=3')
|
command('set laststatus=3')
|
||||||
meths.set_option_value('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T', {})
|
meths.set_option_value('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T', {})
|
||||||
command('vsplit')
|
command('vsplit')
|
||||||
screen:expect([[
|
screen:expect{grid=[[
|
||||||
^ │ |
|
^ │ |
|
||||||
~ │~ |
|
{0:~ }│{0:~ }|
|
||||||
~ │~ |
|
{0:~ }│{0:~ }|
|
||||||
~ │~ |
|
{0:~ }│{0:~ }|
|
||||||
~ │~ |
|
{0:~ }│{0:~ }|
|
||||||
~ │~ |
|
{0:~ }│{0:~ }|
|
||||||
Clicky stuff Clicky stuff|
|
{1:Clicky stuff Clicky stuff}|
|
||||||
|
|
|
|
||||||
]])
|
]]}
|
||||||
|
|
||||||
-- clickable area on the right
|
-- clickable area on the right
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 35)
|
meths.input_mouse('left', 'press', '', 0, 6, 35)
|
||||||
|
|||||||
Reference in New Issue
Block a user