mirror of
https://github.com/neovim/neovim.git
synced 2025-11-28 13:10:44 +00:00
refactor(api): VALIDATE macros #22187
Problem: - API validation involves too much boilerplate. - API validation errors are not consistently worded. Solution: Introduce some macros. Currently these are clumsy, but they at least help with consistency and avoid some nesting.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "klib/kvec.h"
|
||||
#include "nvim/api/private/helpers.h"
|
||||
#include "nvim/api/private/validate.h"
|
||||
#include "nvim/api/ui.h"
|
||||
#include "nvim/ascii.h"
|
||||
#include "nvim/autocmd.h"
|
||||
@@ -608,7 +609,7 @@ Array ui_array(void)
|
||||
return all_uis;
|
||||
}
|
||||
|
||||
void ui_grid_resize(handle_T grid_handle, int width, int height, Error *error)
|
||||
void ui_grid_resize(handle_T grid_handle, int width, int height, Error *err)
|
||||
{
|
||||
if (grid_handle == DEFAULT_GRID_HANDLE) {
|
||||
screen_resize(width, height);
|
||||
@@ -616,11 +617,9 @@ void ui_grid_resize(handle_T grid_handle, int width, int height, Error *error)
|
||||
}
|
||||
|
||||
win_T *wp = get_win_by_grid_handle(grid_handle);
|
||||
if (wp == NULL) {
|
||||
api_set_error(error, kErrorTypeValidation,
|
||||
"No window with the given handle");
|
||||
VALIDATE_INT((wp != NULL), "window handle", (int64_t)grid_handle, {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
if (wp->w_floating) {
|
||||
if (width != wp->w_width || height != wp->w_height) {
|
||||
|
||||
Reference in New Issue
Block a user