Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brammool committed Mar 6, 2018
1 parent 89894aa commit 987723e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/popupmnu.c
Expand Up @@ -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);
Expand Down Expand Up @@ -1171,7 +1171,7 @@ pum_show_popupmenu(vimmenu_T *menu)
int c;

pum_redraw();
setcursor();
setcursor_mayforce(TRUE);
out_flush();

c = vgetc();
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/proto/screen.pro
Expand Up @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion src/screen.c
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -766,6 +766,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1574,
/**/
1573,
/**/
Expand Down

0 comments on commit 987723e

Please sign in to comment.