aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/ui.c28
-rw-r--r--src/nvim/popupmnu.c28
-rw-r--r--src/nvim/ui.c17
3 files changed, 36 insertions, 37 deletions
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index d2d1355207..430be920e2 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -357,11 +357,11 @@ void nvim_ui_pum_set_height(uint64_t channel_id, Integer height, Error *err)
/// including visual decorations such as boarders and sliders.
///
/// @param channel_id
-/// @param width Popupmenu width, must be greater than zero.
-/// @param height Popupmenu height, must be greater than zero.
-/// @param row Popupmenu row, must be greater or equal to zero.
-/// @param col Popupmenu height, must be greater or equal to zero.
-/// @param[out] err Error details, if any. On error, suspend pum position reporting for the current UI.
+/// @param width Popupmenu width.
+/// @param height Popupmenu height.
+/// @param row Popupmenu row.
+/// @param col Popupmenu height.
+/// @param[out] err Error details, if any.
void nvim_ui_pum_set_bounds(uint64_t channel_id, Integer width, Integer height,
Integer row, Integer col, Error *err)
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY
@@ -375,31 +375,21 @@ void nvim_ui_pum_set_bounds(uint64_t channel_id, Integer width, Integer height,
UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
if (!ui->ui_ext[kUIPopupmenu]) {
api_set_error(err, kErrorTypeValidation,
- "It must support the ext_popupmenu option");
+ "UI must support the ext_popupmenu option");
return;
}
if (row < 0) {
api_set_error(err, kErrorTypeValidation, "Expected pumpos row >= 0");
- ui->pum_pos = false;
return;
- }
-
- if (col < 0) {
+ } else if (col < 0) {
api_set_error(err, kErrorTypeValidation, "Expected pumpos col >= 0");
- ui->pum_pos = false;
return;
- }
-
- if (width <= 0) {
+ } else if (width <= 0) {
api_set_error(err, kErrorTypeValidation, "Expected pumpos width > 0");
- ui->pum_pos = false;
return;
- }
-
- if (height <= 0) {
+ } else if (height <= 0) {
api_set_error(err, kErrorTypeValidation, "Expected pumpos height > 0");
- ui->pum_pos = false;
return;
}
diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c
index 9568f319b4..5f636ba847 100644
--- a/src/nvim/popupmnu.c
+++ b/src/nvim/popupmnu.c
@@ -902,6 +902,18 @@ int pum_get_height(void)
return pum_height;
}
+/// Gets the internal pum geometry.
+///
+/// @return the internal pum geometry. Ignores UI external pum geometry.
+/// Only valid when pum_visible() returns TRUE!
+void pum_get_internal_pos(int* pwidth, int* pheight, int* prow, int* pcol)
+{
+ *pwidth = pum_width;
+ *pheight = pum_height;
+ *prow = pum_row;
+ *pcol = pum_col;
+}
+
/// Add size information about the pum to "dict".
void pum_set_event_info(dict_T *dict)
{
@@ -909,17 +921,11 @@ void pum_set_event_info(dict_T *dict)
return;
}
int w,h,r,c;
- if (!ui_pum_get_pos(&w, &h, &r, &c)){
- tv_dict_add_nr(dict, S_LEN("height"), pum_height);
- tv_dict_add_nr(dict, S_LEN("width"), pum_width);
- tv_dict_add_nr(dict, S_LEN("row"), pum_row);
- tv_dict_add_nr(dict, S_LEN("col"), pum_col);
- } else {
- tv_dict_add_nr(dict, S_LEN("height"), h);
- tv_dict_add_nr(dict, S_LEN("width"), w);
- tv_dict_add_nr(dict, S_LEN("row"), r);
- tv_dict_add_nr(dict, S_LEN("col"), c);
- }
+ ui_pum_get_pos(&w, &h, &r, &c);
+ tv_dict_add_nr(dict, S_LEN("height"), h);
+ tv_dict_add_nr(dict, S_LEN("width"), w);
+ tv_dict_add_nr(dict, S_LEN("row"), r);
+ tv_dict_add_nr(dict, S_LEN("col"), c);
tv_dict_add_nr(dict, S_LEN("size"), pum_size);
tv_dict_add_special(dict, S_LEN("scrollbar"),
pum_scrollbar ? kSpecialVarTrue : kSpecialVarFalse);
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index e7cc3b4e36..9ab868c78e 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -226,7 +226,7 @@ int ui_pum_get_height(void)
{
int pum_height = 0;
for (size_t i = 1; i < ui_count; i++) {
- int ui_pum_height = uis[i]->pum_height;
+ int ui_pum_height = uis[i]->pum_nlines;
if (ui_pum_height) {
pum_height =
pum_height != 0 ? MIN(pum_height, ui_pum_height) : ui_pum_height;
@@ -235,7 +235,7 @@ int ui_pum_get_height(void)
return pum_height;
}
-bool ui_pum_get_pos(int* pwidth, int *pheight, int* prow, int* pcol)
+void ui_pum_get_pos(int* pwidth, int *pheight, int* prow, int* pcol)
{
int w=0,h=0,r=-1,c=-1;
bool found = false;
@@ -254,11 +254,14 @@ bool ui_pum_get_pos(int* pwidth, int *pheight, int* prow, int* pcol)
c = MIN(uis[i]->pum_col, c);
}
}
- *pwidth = w;
- *pheight = h;
- *prow = r;
- *pcol = c;
- return found;
+ if (found) {
+ *pwidth = w;
+ *pheight = h;
+ *prow = r;
+ *pcol = c;
+ } else {
+ pum_get_internal_pos(pwidth, pheight, prow, pcol);
+ }
}
static void ui_refresh_event(void **argv)