diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-05-03 10:29:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-03 10:29:19 +0800 |
commit | dc394b9641f92a5014147da58f5e14fd1681ec0f (patch) | |
tree | 76812ab57c590341d9ce8a960d87e4af1f86ca83 | |
parent | a4bb8c37dbe9233662e0adaf7ad34fb4f094d114 (diff) | |
download | rneovim-dc394b9641f92a5014147da58f5e14fd1681ec0f.tar.gz rneovim-dc394b9641f92a5014147da58f5e14fd1681ec0f.tar.bz2 rneovim-dc394b9641f92a5014147da58f5e14fd1681ec0f.zip |
fix(mouse): fix popup menu position check with winbar (#23456)
-rw-r--r-- | src/nvim/mouse.c | 2 | ||||
-rw-r--r-- | test/functional/ui/mouse_spec.lua | 11 | ||||
-rw-r--r-- | test/functional/ui/popupmenu_spec.lua | 73 |
3 files changed, 85 insertions, 1 deletions
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index 79bd65a88f..8189fde83c 100644 --- 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 index d9b9cf9f1b..2c0a00c74f 100644 --- 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 index 61b815dbf6..76038472bd 100644 --- 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 |