Skip to content

Commit

Permalink
fix(mouse): click on global statusline with splits (neovim#19390)
Browse files Browse the repository at this point in the history
  • Loading branch information
MunifTanjim authored and smjonas committed Dec 31, 2022
1 parent e2da4ae commit f668e4c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/nvim/normal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
30 changes: 29 additions & 1 deletion test/functional/ui/statusline_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f668e4c

Please sign in to comment.