diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-12-31 17:41:01 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-12-31 17:41:01 +0100 |
commit | dd1f426bd617ac6a775f2e7795ff0b159e3fa315 (patch) | |
tree | 4ff4b05181d01272e12a482a91dec6a6ef5095bc /src/typval.c | |
parent | ca2f7e7af32d51c2be378a5298bc85958c877653 (diff) | |
download | vim-git-dd1f426bd617ac6a775f2e7795ff0b159e3fa315.tar.gz |
patch 8.2.2254: Vim9: bool option type is numberv8.2.2254
Problem: Vim9: bool option type is number.
Solution: Have get_option_value() return a different value for bool and
number options. (closes #7583)
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 df3bc92a4..421e62a37 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 |