Merge pull request #22910 from bfredl/nonormal

fix(highlight): use winhl=Foo:Bar even when Bar is empty
This commit is contained in:
bfredl
2023-04-06 17:38:16 +02:00
committed by GitHub
6 changed files with 100 additions and 14 deletions

View File

@@ -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;
});

View File

@@ -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)) { \