Skip to content

Commit 987723e

Browse files
committed
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.
1 parent 89894aa commit 987723e

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

src/popupmnu.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,14 +1104,14 @@ pum_select_mouse_pos(void)
11041104
* Execute the currently selected popup menu item.
11051105
*/
11061106
static void
1107-
pum_execute_menu(vimmenu_T *menu)
1107+
pum_execute_menu(vimmenu_T *menu, int mode)
11081108
{
11091109
vimmenu_T *mp;
11101110
int idx = 0;
11111111
exarg_T ea;
11121112

11131113
for (mp = menu->children; mp != NULL; mp = mp->next)
1114-
if (idx++ == pum_selected)
1114+
if ((mp->modes & mp->enabled & mode) && idx++ == pum_selected)
11151115
{
11161116
vim_memset(&ea, 0, sizeof(ea));
11171117
execute_menu(&ea, mp);
@@ -1171,7 +1171,7 @@ pum_show_popupmenu(vimmenu_T *menu)
11711171
int c;
11721172

11731173
pum_redraw();
1174-
setcursor();
1174+
setcursor_mayforce(TRUE);
11751175
out_flush();
11761176

11771177
c = vgetc();
@@ -1180,7 +1180,7 @@ pum_show_popupmenu(vimmenu_T *menu)
11801180
else if (c == CAR || c == NL)
11811181
{
11821182
/* enter: select current item, if any, and close */
1183-
pum_execute_menu(menu);
1183+
pum_execute_menu(menu, mode);
11841184
break;
11851185
}
11861186
else if (c == 'k' || c == K_UP || c == K_MOUSEUP)
@@ -1221,7 +1221,7 @@ pum_show_popupmenu(vimmenu_T *menu)
12211221
pum_select_mouse_pos();
12221222
if (pum_selected >= 0)
12231223
{
1224-
pum_execute_menu(menu);
1224+
pum_execute_menu(menu, mode);
12251225
break;
12261226
}
12271227
if (c == K_LEFTMOUSE || c == K_LEFTMOUSE_NM)

src/proto/screen.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ int can_clear(char_u *p);
4444
void screen_start(void);
4545
void windgoto(int row, int col);
4646
void setcursor(void);
47+
void setcursor_mayforce(int force);
4748
int win_ins_lines(win_T *wp, int row, int line_count, int invalid, int mayclear);
4849
int win_del_lines(win_T *wp, int row, int line_count, int invalid, int mayclear, int clear_attr);
4950
int screen_ins_lines(int off, int row, int line_count, int end, int clear_attr, win_T *wp);

src/screen.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9471,7 +9471,17 @@ windgoto(int row, int col)
94719471
void
94729472
setcursor(void)
94739473
{
9474-
if (redrawing())
9474+
setcursor_mayforce(FALSE);
9475+
}
9476+
9477+
/*
9478+
* Set cursor to its position in the current window.
9479+
* When "force" is TRUE also when not redrawing.
9480+
*/
9481+
void
9482+
setcursor_mayforce(int force)
9483+
{
9484+
if (force || redrawing())
94759485
{
94769486
validate_cursor();
94779487
windgoto(W_WINROW(curwin) + curwin->w_wrow,

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ static char *(features[]) =
766766

767767
static int included_patches[] =
768768
{ /* Add new patch number below this line */
769+
/**/
770+
1574,
769771
/**/
770772
1573,
771773
/**/

0 commit comments

Comments
 (0)