aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/popupmenu.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-10-28 14:29:59 +0800
committerGitHub <noreply@github.com>2024-10-28 14:29:59 +0800
commitd24fb72c335be905d0b7f2c67f9b988f07703d1f (patch)
tree308c69dddee6d331e4de39ae13f11d043ce8e3cc /src/nvim/popupmenu.c
parent7a20f93a929abda22f979e92fd75b92e447d1e2a (diff)
downloadrneovim-d24fb72c335be905d0b7f2c67f9b988f07703d1f.tar.gz
rneovim-d24fb72c335be905d0b7f2c67f9b988f07703d1f.tar.bz2
rneovim-d24fb72c335be905d0b7f2c67f9b988f07703d1f.zip
fix(pum): don't select item when clicking to the left/right (#30967)
Problem: Selecting an item in the right-click menu when clicking to the left/right of it is confusing, especially in a UI that doesn't support 'mousemoveevent'. Solution: Don't select an item when clicking to the left/right of the right-click menu.
Diffstat (limited to 'src/nvim/popupmenu.c')
-rw-r--r--src/nvim/popupmenu.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index 87ef6a27ad..529d65c5dc 100644
--- a/src/nvim/popupmenu.c
+++ b/src/nvim/popupmenu.c
@@ -1358,14 +1358,15 @@ static void pum_select_mouse_pos(void)
if (mouse_grid == pum_grid.handle) {
pum_selected = mouse_row;
return;
- } else if (mouse_grid != pum_anchor_grid) {
+ } else if (mouse_grid != pum_anchor_grid || mouse_col < pum_grid.comp_col
+ || mouse_col >= pum_grid.comp_col + pum_grid.comp_width) {
pum_selected = -1;
return;
}
- int idx = mouse_row - pum_row;
+ int idx = mouse_row - pum_grid.comp_row;
- if (idx < 0 || idx >= pum_height) {
+ if (idx < 0 || idx >= pum_grid.comp_height) {
pum_selected = -1;
} else if (*pum_array[idx].pum_text != NUL) {
pum_selected = idx;