diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2023-02-14 05:19:04 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-14 02:19:04 -0800 |
commit | 46a87a5d2bac598fed0870f0d3c926087f95d30f (patch) | |
tree | 500dba055ff89fcc0610e7a497d7a4471bff04f1 /src/nvim/option.c | |
parent | 53968082675cd3b8d1809e53a47c0311b7347ef9 (diff) | |
download | rneovim-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/option.c')
-rw-r--r-- | src/nvim/option.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 5ece5e4e5d..1d7747de0b 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -33,6 +33,7 @@ #include "nvim/api/extmark.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" +#include "nvim/api/private/validate.h" #include "nvim/ascii.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" @@ -5624,10 +5625,9 @@ long get_sidescrolloff_value(win_T *wp) Dictionary get_vimoption(String name, Error *err) { int opt_idx = findoption_len((const char *)name.data, name.size); - if (opt_idx < 0) { - api_set_error(err, kErrorTypeValidation, "no such option: '%s'", name.data); + VALIDATE_S(opt_idx >= 0, "option (not found)", name.data, { return (Dictionary)ARRAY_DICT_INIT; - } + }); return vimoption2dict(&options[opt_idx]); } |