multigrid: use grid-based coordinates for ext_popupmenu

This commit is contained in:
Björn Linse 2018-09-08 10:35:09 +02:00
parent 882dd63dc7
commit 16c3337122
2 changed files with 14 additions and 6 deletions

View File

@ -87,7 +87,8 @@ void win_position(Integer win, Integer grid, Integer startrow,
Integer startcol, Integer width, Integer height)
FUNC_API_SINCE(4) FUNC_API_REMOTE_ONLY;
void popupmenu_show(Array items, Integer selected, Integer row, Integer col)
void popupmenu_show(Array items, Integer selected,
Integer row, Integer col, Integer grid)
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
void popupmenu_hide(void)
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;

View File

@ -68,12 +68,12 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed)
int kind_width;
int extra_width;
int i;
int row;
int context_lines;
int col;
int above_row;
int below_row;
int redo_count = 0;
int row;
int col;
if (!pum_is_visible) {
// To keep the code simple, we only allow changing the
@ -90,13 +90,20 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed)
below_row = cmdline_row;
// anchor position: the start of the completed word
row = curwin->w_wrow + curwin->w_winrow;
row = curwin->w_wrow;
if (curwin->w_p_rl) {
col = curwin->w_wincol + curwin->w_width - curwin->w_wcol - 1;
col = curwin->w_width - curwin->w_wcol - 1;
} else {
col = curwin->w_wincol + curwin->w_wcol;
}
int grid = (int)curwin->w_grid.handle;
if (!ui_is_external(kUIMultigrid)) {
grid = (int)default_grid.handle;
row += curwin->w_winrow;
col += curwin->w_wincol;
}
if (pum_external) {
if (array_changed) {
Array arr = ARRAY_DICT_INIT;
@ -108,7 +115,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed)
ADD(item, STRING_OBJ(cstr_to_string((char *)array[i].pum_info)));
ADD(arr, ARRAY_OBJ(item));
}
ui_call_popupmenu_show(arr, selected, row, col);
ui_call_popupmenu_show(arr, selected, row, col, grid);
} else {
ui_call_popupmenu_select(selected);
}