mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
api/ui: allow set bounds row and col to be less than 0; ui_pum_get_pos: return first extui bounds information instead of reducing
This commit is contained in:
@@ -382,17 +382,11 @@ void nvim_ui_pum_set_bounds(uint64_t channel_id, Float width, Float height,
|
||||
return;
|
||||
}
|
||||
|
||||
if (row < 0) {
|
||||
api_set_error(err, kErrorTypeValidation, "Expected pumpos row >= 0");
|
||||
return;
|
||||
} else if (col < 0) {
|
||||
api_set_error(err, kErrorTypeValidation, "Expected pumpos col >= 0");
|
||||
return;
|
||||
} else if (width <= 0) {
|
||||
api_set_error(err, kErrorTypeValidation, "Expected pumpos width > 0");
|
||||
if (width <= 0) {
|
||||
api_set_error(err, kErrorTypeValidation, "Expected width > 0");
|
||||
return;
|
||||
} else if (height <= 0) {
|
||||
api_set_error(err, kErrorTypeValidation, "Expected pumpos height > 0");
|
||||
api_set_error(err, kErrorTypeValidation, "Expected height > 0");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -237,24 +237,18 @@ int ui_pum_get_height(void)
|
||||
|
||||
void ui_pum_get_pos(double *pwidth, double *pheight, double *prow, double *pcol)
|
||||
{
|
||||
double w = 0.0, h = 0.0, r = -1.0, c = -1.0;
|
||||
double w = 0.0, h = 0.0, r = 0.0, c = 0.0;
|
||||
bool found = false;
|
||||
for (size_t i = 1; i < ui_count; i++) {
|
||||
if (!uis[i]->pum_pos) {
|
||||
continue;
|
||||
}
|
||||
if (!found) {
|
||||
w = uis[i]->pum_width;
|
||||
h = uis[i]->pum_height;
|
||||
r = uis[i]->pum_row;
|
||||
c = uis[i]->pum_col;
|
||||
found = true;
|
||||
} else {
|
||||
w = MIN(uis[i]->pum_width, w);
|
||||
h = MIN(uis[i]->pum_height, h);
|
||||
r = MIN(uis[i]->pum_row, r);
|
||||
c = MIN(uis[i]->pum_col, c);
|
||||
}
|
||||
w = uis[i]->pum_width;
|
||||
h = uis[i]->pum_height;
|
||||
r = uis[i]->pum_row;
|
||||
c = uis[i]->pum_col;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if (found) {
|
||||
*pwidth = w;
|
||||
|
@@ -481,16 +481,14 @@ describe('ui/ext_popupmenu', function()
|
||||
}}
|
||||
end)
|
||||
|
||||
it('an error occurs if row or col set less than 0', function()
|
||||
it('no error occurs if row or col set less than 0', function()
|
||||
local ok, err, _
|
||||
ok, _ = pcall(meths.ui_pum_set_bounds, 1.0, 1.0, 0.0, 1.5)
|
||||
eq(true, ok)
|
||||
ok, err = pcall(meths.ui_pum_set_bounds, 1.0, 1.0, -1.0, 0.0)
|
||||
eq(false, ok)
|
||||
matches('.*: Expected pumpos row >= 0', err)
|
||||
ok, err = pcall(meths.ui_pum_set_bounds, 1.0, 1.0, 0.0, -1.0)
|
||||
eq(false, ok)
|
||||
matches('.*: Expected pumpos col >= 0', err)
|
||||
ok, _ = pcall(meths.ui_pum_set_bounds, 1.0, 1.0, -1.0, 0.0)
|
||||
eq(true, ok)
|
||||
ok, _ = pcall(meths.ui_pum_set_bounds, 1.0, 1.0, 0.0, -1.0)
|
||||
eq(true, ok)
|
||||
end)
|
||||
|
||||
it('an error occurs if width or height set 0 or less', function()
|
||||
|
Reference in New Issue
Block a user