diff options
author | Munif Tanjim <hello@muniftanjim.dev> | 2022-07-19 04:35:04 +0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-19 06:35:04 +0800 |
commit | a80d447b47c22985a467ce9d2aaf214e966ca642 (patch) | |
tree | bcb1be6273ee2a38e152d135d76ad22e94e206af | |
parent | 3340728c723833c093527b719b25c1cc9efaf598 (diff) | |
download | rneovim-a80d447b47c22985a467ce9d2aaf214e966ca642.tar.gz rneovim-a80d447b47c22985a467ce9d2aaf214e966ca642.tar.bz2 rneovim-a80d447b47c22985a467ce9d2aaf214e966ca642.zip |
fix(mouse): click on global statusline with splits (#19390)
-rw-r--r-- | src/nvim/normal.c | 7 | ||||
-rw-r--r-- | test/functional/ui/statusline_spec.lua | 30 |
2 files changed, 36 insertions, 1 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index b675abfb7d..a842bb20a9 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -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: diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 1e1066d48a..2ffd3149a6 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -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() |