aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-06-30 15:55:38 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-07-01 10:17:39 +0800
commite4c2ff2da4fb1986e0cd88e6eea9d49ddaec9817 (patch)
treee18a2961aceb5788ec6889a5032d7b6d96f6af16
parent610cf9f95032bd219cb5695d169fe2cd698ec307 (diff)
downloadrneovim-e4c2ff2da4fb1986e0cd88e6eea9d49ddaec9817.tar.gz
rneovim-e4c2ff2da4fb1986e0cd88e6eea9d49ddaec9817.tar.bz2
rneovim-e4c2ff2da4fb1986e0cd88e6eea9d49ddaec9817.zip
vim-patch:8.0.1574: show cursor in wrong place when using popup menu
Problem: Show cursor in wrong place when using popup menu. (Wei Zhang) Solution: Force updating the cursor position. Fix skipping over unused entries. https://github.com/vim/vim/commit/987723e084660290270b3c3d943eb13bd828d5da
-rw-r--r--src/nvim/popupmnu.c10
-rw-r--r--src/nvim/screen.c13
2 files changed, 14 insertions, 9 deletions
diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c
index 82ad409c39..515fecb036 100644
--- a/src/nvim/popupmnu.c
+++ b/src/nvim/popupmnu.c
@@ -981,13 +981,13 @@ static void pum_select_mouse_pos(void)
}
/// Execute the currently selected popup menu item.
-static void pum_execute_menu(vimmenu_T *menu)
+static void pum_execute_menu(vimmenu_T *menu, int mode)
{
int idx = 0;
exarg_T ea;
for (vimmenu_T *mp = menu->children; mp != NULL; mp = mp->next) {
- if (idx++ == pum_selected) {
+ if ((mp->modes & mp->enabled & mode) && idx++ == pum_selected) {
memset(&ea, 0, sizeof(ea));
execute_menu(&ea, mp);
break;
@@ -1032,7 +1032,7 @@ void pum_show_popupmenu(vimmenu_T *menu)
pum_is_visible = true;
pum_is_drawn = true;
pum_redraw();
- setcursor();
+ setcursor_mayforce(true);
ui_flush();
int c = vgetc();
@@ -1040,7 +1040,7 @@ void pum_show_popupmenu(vimmenu_T *menu)
break;
} else if (c == CAR || c == NL) {
// enter: select current item, if any, and close
- pum_execute_menu(menu);
+ pum_execute_menu(menu, mode);
break;
} else if (c == 'k' || c == K_UP || c == K_MOUSEUP) {
// cursor up: select previous item
@@ -1070,7 +1070,7 @@ void pum_show_popupmenu(vimmenu_T *menu)
// right mouse release: select clicked item, close if any
pum_select_mouse_pos();
if (pum_selected >= 0) {
- pum_execute_menu(menu);
+ pum_execute_menu(menu, mode);
break;
}
if (c == K_LEFTMOUSE || c == K_LEFTMOUSE_NM) {
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 78b0d6b841..c2a88bb4a6 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -5757,12 +5757,17 @@ static void linecopy(ScreenGrid *grid, int to, int from, int col, int width)
width * sizeof(sattr_T));
}
-/*
- * Set cursor to its position in the current window.
- */
+/// Set cursor to its position in the current window.
void setcursor(void)
{
- if (redrawing()) {
+ setcursor_mayforce(false);
+}
+
+/// Set cursor to its position in the current window.
+/// @param force when true, also when not redrawing.
+void setcursor_mayforce(bool force)
+{
+ if (force || redrawing()) {
validate_cursor();
ScreenGrid *grid = &curwin->w_grid;