diff options
Diffstat (limited to 'src/typval.c')
-rw-r--r-- | src/typval.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/typval.c b/src/typval.c index df3bc92a4c..421e62a37c 100644 --- a/src/typval.c +++ b/src/typval.c @@ -1083,7 +1083,7 @@ eval_option( char_u *option_end; long numval; char_u *stringval; - int opt_type; + getoption_T opt_type; int c; int working = (**arg == '+'); // has("+option") int ret = OK; @@ -1109,7 +1109,7 @@ eval_option( opt_type = get_option_value(*arg, &numval, rettv == NULL ? NULL : &stringval, opt_flags); - if (opt_type == -3) // invalid name + if (opt_type == gov_unknown) { if (rettv != NULL) semsg(_(e_unknown_option), *arg); @@ -1117,20 +1117,29 @@ eval_option( } else if (rettv != NULL) { - if (opt_type == -2) // hidden string option + if (opt_type == gov_hidden_string) { rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; } - else if (opt_type == -1) // hidden number option + else if (opt_type == gov_hidden_bool || opt_type == gov_hidden_number) { - rettv->v_type = VAR_NUMBER; + rettv->v_type = in_vim9script() && opt_type == gov_hidden_bool + ? VAR_BOOL : VAR_NUMBER; rettv->vval.v_number = 0; } - else if (opt_type == 1) // number option + else if (opt_type == gov_bool || opt_type == gov_number) { - rettv->v_type = VAR_NUMBER; - rettv->vval.v_number = numval; + if (in_vim9script() && opt_type == gov_bool) + { + rettv->v_type = VAR_BOOL; + rettv->vval.v_number = numval ? VVAL_TRUE : VVAL_FALSE; + } + else + { + rettv->v_type = VAR_NUMBER; + rettv->vval.v_number = numval; + } } else // string option { @@ -1138,7 +1147,9 @@ eval_option( rettv->vval.v_string = stringval; } } - else if (working && (opt_type == -2 || opt_type == -1)) + else if (working && (opt_type == gov_hidden_bool + || opt_type == gov_hidden_number + || opt_type == gov_hidden_string)) ret = FAIL; *option_end = c; // put back for error messages |