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.
This commit is contained in:
zeertzjq
2024-10-28 14:29:59 +08:00
committed by GitHub
parent 7a20f93a92
commit d24fb72c33
2 changed files with 78 additions and 7 deletions

View File

@@ -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;