mirror of
https://github.com/neovim/neovim.git
synced 2025-10-03 08:28:34 +00:00
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.
987723e084
This commit is contained in:
@@ -981,13 +981,13 @@ static void pum_select_mouse_pos(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Execute the currently selected popup menu item.
|
/// 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;
|
int idx = 0;
|
||||||
exarg_T ea;
|
exarg_T ea;
|
||||||
|
|
||||||
for (vimmenu_T *mp = menu->children; mp != NULL; mp = mp->next) {
|
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));
|
memset(&ea, 0, sizeof(ea));
|
||||||
execute_menu(&ea, mp);
|
execute_menu(&ea, mp);
|
||||||
break;
|
break;
|
||||||
@@ -1032,7 +1032,7 @@ void pum_show_popupmenu(vimmenu_T *menu)
|
|||||||
pum_is_visible = true;
|
pum_is_visible = true;
|
||||||
pum_is_drawn = true;
|
pum_is_drawn = true;
|
||||||
pum_redraw();
|
pum_redraw();
|
||||||
setcursor();
|
setcursor_mayforce(true);
|
||||||
ui_flush();
|
ui_flush();
|
||||||
|
|
||||||
int c = vgetc();
|
int c = vgetc();
|
||||||
@@ -1040,7 +1040,7 @@ void pum_show_popupmenu(vimmenu_T *menu)
|
|||||||
break;
|
break;
|
||||||
} else if (c == CAR || c == NL) {
|
} else if (c == CAR || c == NL) {
|
||||||
// enter: select current item, if any, and close
|
// enter: select current item, if any, and close
|
||||||
pum_execute_menu(menu);
|
pum_execute_menu(menu, mode);
|
||||||
break;
|
break;
|
||||||
} else if (c == 'k' || c == K_UP || c == K_MOUSEUP) {
|
} else if (c == 'k' || c == K_UP || c == K_MOUSEUP) {
|
||||||
// cursor up: select previous item
|
// 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
|
// right mouse release: select clicked item, close if any
|
||||||
pum_select_mouse_pos();
|
pum_select_mouse_pos();
|
||||||
if (pum_selected >= 0) {
|
if (pum_selected >= 0) {
|
||||||
pum_execute_menu(menu);
|
pum_execute_menu(menu, mode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (c == K_LEFTMOUSE || c == K_LEFTMOUSE_NM) {
|
if (c == K_LEFTMOUSE || c == K_LEFTMOUSE_NM) {
|
||||||
|
@@ -5757,12 +5757,17 @@ static void linecopy(ScreenGrid *grid, int to, int from, int col, int width)
|
|||||||
width * sizeof(sattr_T));
|
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)
|
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();
|
validate_cursor();
|
||||||
|
|
||||||
ScreenGrid *grid = &curwin->w_grid;
|
ScreenGrid *grid = &curwin->w_grid;
|
||||||
|
Reference in New Issue
Block a user