diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-03-06 11:43:04 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-03-06 11:43:04 +0100 |
commit | 987723e084660290270b3c3d943eb13bd828d5da (patch) | |
tree | e7f0329145672eccca05d6e4498b8345bf2c8e8c | |
parent | 89894aa671ed1db03d95d38cab300702c242239d (diff) | |
download | vim-git-987723e084660290270b3c3d943eb13bd828d5da.tar.gz |
patch 8.0.1574: show cursor in wrong place when using popup menuv8.0.1574
Problem: Show cursor in wrong place when using popup menu. (Wei Zhang)
Solution: Force updating the cursor position. Fix skipping over unused
entries.
-rw-r--r-- | src/popupmnu.c | 10 | ||||
-rw-r--r-- | src/proto/screen.pro | 1 | ||||
-rw-r--r-- | src/screen.c | 12 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 19 insertions, 6 deletions
diff --git a/src/popupmnu.c b/src/popupmnu.c index 9b5f750f8..985a0e62f 100644 --- a/src/popupmnu.c +++ b/src/popupmnu.c @@ -1104,14 +1104,14 @@ pum_select_mouse_pos(void) * Execute the currently selected popup menu item. */ static void -pum_execute_menu(vimmenu_T *menu) +pum_execute_menu(vimmenu_T *menu, int mode) { vimmenu_T *mp; int idx = 0; exarg_T ea; for (mp = menu->children; mp != NULL; mp = mp->next) - if (idx++ == pum_selected) + if ((mp->modes & mp->enabled & mode) && idx++ == pum_selected) { vim_memset(&ea, 0, sizeof(ea)); execute_menu(&ea, mp); @@ -1171,7 +1171,7 @@ pum_show_popupmenu(vimmenu_T *menu) int c; pum_redraw(); - setcursor(); + setcursor_mayforce(TRUE); out_flush(); c = vgetc(); @@ -1180,7 +1180,7 @@ pum_show_popupmenu(vimmenu_T *menu) 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) @@ -1221,7 +1221,7 @@ pum_show_popupmenu(vimmenu_T *menu) 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/proto/screen.pro b/src/proto/screen.pro index 39424b485..f04fda51e 100644 --- a/src/proto/screen.pro +++ b/src/proto/screen.pro @@ -44,6 +44,7 @@ int can_clear(char_u *p); void screen_start(void); void windgoto(int row, int col); void setcursor(void); +void setcursor_mayforce(int force); int win_ins_lines(win_T *wp, int row, int line_count, int invalid, int mayclear); int win_del_lines(win_T *wp, int row, int line_count, int invalid, int mayclear, int clear_attr); int screen_ins_lines(int off, int row, int line_count, int end, int clear_attr, win_T *wp); diff --git a/src/screen.c b/src/screen.c index 935f9810c..5ab2e85fc 100644 --- a/src/screen.c +++ b/src/screen.c @@ -9471,7 +9471,17 @@ windgoto(int row, int col) void setcursor(void) { - if (redrawing()) + setcursor_mayforce(FALSE); +} + +/* + * Set cursor to its position in the current window. + * When "force" is TRUE also when not redrawing. + */ + void +setcursor_mayforce(int force) +{ + if (force || redrawing()) { validate_cursor(); windgoto(W_WINROW(curwin) + curwin->w_wrow, diff --git a/src/version.c b/src/version.c index 8fd5ea738..3cf255018 100644 --- a/src/version.c +++ b/src/version.c @@ -767,6 +767,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1574, +/**/ 1573, /**/ 1572, |