fix(mouse): click on global statusline with splits (#19390)

This commit is contained in:
Munif Tanjim
2022-07-19 04:35:04 +06:00
committed by GitHub
parent 3340728c72
commit a80d447b47
2 changed files with 36 additions and 1 deletions

View File

@@ -1908,6 +1908,13 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
StlClickDefinition *click_defs = in_status_line ? wp->w_status_click_defs
: wp->w_winbar_click_defs;
if (in_status_line && global_stl_height() > 0) {
// global statusline is displayed for the current window,
// and spans the whole screen.
click_defs = curwin->w_status_click_defs;
click_col = mouse_col;
}
if (click_defs != NULL) {
switch (click_defs[click_col].type) {
case kStlClickDisabled:

View File

@@ -98,13 +98,41 @@ describe('statusline clicks', function()
eq('0 2 r', eval("g:testvar"))
end)
it("click works with modifiers #18994", function()
it("works with modifiers #18994", function()
meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
meths.input_mouse('right', 'press', 's', 0, 6, 17)
eq('0 1 r s', eval("g:testvar"))
meths.input_mouse('left', 'press', 's', 0, 6, 17)
eq('0 1 l s', eval("g:testvar"))
end)
it("works for global statusline with vertical splits #19186", function()
command('set laststatus=3')
meths.set_option('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T')
command('vsplit')
screen:expect([[
^ │ |
~ │~ |
~ │~ |
~ │~ |
~ │~ |
~ │~ |
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)
end)
describe('global statusline', function()