neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit dc394b9641f92a5014147da58f5e14fd1681ec0f
parent a4bb8c37dbe9233662e0adaf7ad34fb4f094d114
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Wed,  3 May 2023 10:29:19 +0800

fix(mouse): fix popup menu position check with winbar (#23456)


Diffstat:
Msrc/nvim/mouse.c | 2+-
Mtest/functional/ui/mouse_spec.lua | 11+++++++++++
Mtest/functional/ui/popupmenu_spec.lua | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c @@ -223,7 +223,7 @@ static int get_fpos_of_mouse(pos_T *mpos) } // winpos and height may change in win_enter()! - if (winrow + wp->w_winbar_height >= wp->w_height_inner) { // In (or below) status line + if (winrow >= wp->w_height_inner) { // In (or below) status line return IN_STATUS_LINE; } diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua @@ -1861,5 +1861,16 @@ describe('ui/mouse/input', function() feed('<Down><CR>') eq({1, 9}, meths.win_get_cursor(0)) eq('ran away', funcs.getreg('"')) + + -- Test for right click inside visual selection at bottom of window with winbar + command('setlocal winbar=WINBAR') + feed('2yyP') + funcs.setreg('"', '') + feed('G$vbb') + meths.input_mouse('right', 'press', '', 0, 4, 61) + meths.input_mouse('right', 'release', '', 0, 4, 61) + feed('<Down><CR>') + eq({4, 20}, meths.win_get_cursor(0)) + eq('the moon', funcs.getreg('"')) end) end) diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua @@ -4509,6 +4509,79 @@ describe('builtin popupmenu', function() ]]) end eq('foo', meths.get_var('menustr')) + + command('setlocal winbar=WINBAR') + if multigrid then + meths.input_mouse('right', 'press', '', 6, 1, 14) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + {3:[No Name] [+] }| + [5:---------------]│[6:----------------]| + [5:---------------]│[6:----------------]| + [3:--------------------------------]| + ## grid 2 + popup menu test | + {1:~ }| + ## grid 3 + :let g:menustr = 'foo' | + ## grid 4 + {n: foo}| + {n: bar}| + {n: baz}| + ## grid 5 + popup menu test| + {1:~ }| + ## grid 6 + {2:WINBAR }| + ^popup menu test | + ]], float_pos={[4] = {{id = -1}, "SW", 6, 1, 12, false, 250}}}) + else + feed('<RightMouse><30,4>') + screen:expect([[ + popup menu test | + {1:~ }{n: foo}| + {3:[No Name] [+] }{n: bar}| + popup menu test│{2:WINBAR }{n: baz}| + {1:~ }│^popup menu test | + :let g:menustr = 'foo' | + ]]) + end + if multigrid then + meths.input_mouse('left', 'press', '', 4, 1, 2) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + {3:[No Name] [+] }| + [5:---------------]│[6:----------------]| + [5:---------------]│[6:----------------]| + [3:--------------------------------]| + ## grid 2 + popup menu test | + {1:~ }| + ## grid 3 + :let g:menustr = 'bar' | + ## grid 5 + popup menu test| + {1:~ }| + ## grid 6 + {2:WINBAR }| + ^popup menu test | + ]]}) + else + feed('<LeftMouse><31,2>') + screen:expect([[ + popup menu test | + {1:~ }| + {3:[No Name] [+] }| + popup menu test│{2:WINBAR }| + {1:~ }│^popup menu test | + :let g:menustr = 'bar' | + ]]) + end + eq('bar', meths.get_var('menustr')) end) if not multigrid then