diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-04-06 17:38:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-06 17:38:16 +0200 |
commit | dd80ee0ca948bb548a8af804523ea7ea29c18279 (patch) | |
tree | 25160427c07459cdc4b9a12a4672af62c5830ab8 /src/nvim/api | |
parent | e29bc03c046b3a137c2e36b4d34c119b277d62b2 (diff) | |
parent | 0f42aa1f2a860ce6d72a825b397fe09c875613b5 (diff) | |
download | rneovim-dd80ee0ca948bb548a8af804523ea7ea29c18279.tar.gz rneovim-dd80ee0ca948bb548a8af804523ea7ea29c18279.tar.bz2 rneovim-dd80ee0ca948bb548a8af804523ea7ea29c18279.zip |
Merge pull request #22910 from bfredl/nonormal
fix(highlight): use winhl=Foo:Bar even when Bar is empty
Diffstat (limited to 'src/nvim/api')
-rw-r--r-- | src/nvim/api/options.c | 4 | ||||
-rw-r--r-- | src/nvim/api/private/validate.h | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c index 3e7f7e8781..467a4720a6 100644 --- a/src/nvim/api/options.c +++ b/src/nvim/api/options.c @@ -53,7 +53,7 @@ static int validate_option_value_args(Dict(option) *opts, int *scope, int *opt_t } if (HAS_KEY(opts->win)) { - VALIDATE_T("win", kObjectTypeInteger, opts->win.type, { + VALIDATE_T_HANDLE("win", kObjectTypeWindow, opts->win.type, { return FAIL; }); @@ -65,7 +65,7 @@ static int validate_option_value_args(Dict(option) *opts, int *scope, int *opt_t } if (HAS_KEY(opts->buf)) { - VALIDATE_T("buf", kObjectTypeInteger, opts->buf.type, { + VALIDATE_T_HANDLE("buf", kObjectTypeBuffer, opts->buf.type, { return FAIL; }); diff --git a/src/nvim/api/private/validate.h b/src/nvim/api/private/validate.h index 91a92c2762..a3e77ea838 100644 --- a/src/nvim/api/private/validate.h +++ b/src/nvim/api/private/validate.h @@ -67,6 +67,15 @@ } \ } while (0) +/// Checks that actual_t is either the correct handle type or a type erased handle (integer) +#define VALIDATE_T_HANDLE(name, expected_t, actual_t, code) \ + do { \ + if (expected_t != actual_t && kObjectTypeInteger != actual_t) { \ + api_err_exp(err, name, api_typename(expected_t), api_typename(actual_t)); \ + code; \ + } \ + } while (0) + #define VALIDATE_RANGE(cond, name, code) \ do { \ if (!(cond)) { \ |