aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ui.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-02-14 05:19:04 -0500
committerGitHub <noreply@github.com>2023-02-14 02:19:04 -0800
commit46a87a5d2bac598fed0870f0d3c926087f95d30f (patch)
tree500dba055ff89fcc0610e7a497d7a4471bff04f1 /src/nvim/ui.c
parent53968082675cd3b8d1809e53a47c0311b7347ef9 (diff)
downloadrneovim-46a87a5d2bac598fed0870f0d3c926087f95d30f.tar.gz
rneovim-46a87a5d2bac598fed0870f0d3c926087f95d30f.tar.bz2
rneovim-46a87a5d2bac598fed0870f0d3c926087f95d30f.zip
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.
Diffstat (limited to 'src/nvim/ui.c')
-rw-r--r--src/nvim/ui.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 8172a46773..1693595ce8 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -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) {