diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-12-23 13:56:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-23 13:56:32 +0800 |
commit | 30f606fc602f835fbed869140d3d658e24129c22 (patch) | |
tree | 5af7b1091fa420b81d753e3d9f7a02f78afeb24c /src | |
parent | 98daaa798e018071876d026a60840991be8d8069 (diff) | |
download | rneovim-30f606fc602f835fbed869140d3d658e24129c22.tar.gz rneovim-30f606fc602f835fbed869140d3d658e24129c22.tar.bz2 rneovim-30f606fc602f835fbed869140d3d658e24129c22.zip |
fix(options): restore exists() behavior for options (#21510)
Duplicating get_option_value() logic for an obscure future refactor
isn't really worthwhile, and findoption() isn't used anywhere else
outside the options code.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 5 | ||||
-rw-r--r-- | src/nvim/eval/funcs.c | 11 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d9081680ae..7bae8dff00 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -3674,6 +3674,7 @@ static int eval_index(char **arg, typval_T *rettv, int evaluate, int verbose) int get_option_tv(const char **const arg, typval_T *const rettv, const bool evaluate) FUNC_ATTR_NONNULL_ARG(1) { + const bool working = (**arg == '+'); // has("+option") int scope; // Isolate the option name and find its value. @@ -3718,6 +3719,10 @@ int get_option_tv(const char **const arg, typval_T *const rettv, const bool eval rettv->v_type = VAR_STRING; rettv->vval.v_string = stringval; } + } 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 diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 8bdb91ebf1..eb34869fac 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -1721,14 +1721,9 @@ static void f_exists(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) xfree(exp); } } else if (*p == '&' || *p == '+') { // Option. - bool working = (*p == '+'); // whether option needs to be working - int opt_flags; - - if (find_option_end(&p, &opt_flags) != NULL) { - int opt_idx = findoption(p); - n = (opt_idx >= 0 && (!working || get_varp_scope(get_option(opt_idx), opt_flags) != NULL)); - } else { - n = false; + n = (get_option_tv(&p, NULL, true) == OK); + if (*skipwhite(p) != NUL) { + n = false; // Trailing garbage. } } else if (*p == '*') { // Internal or user defined function. n = function_exists(p + 1, false); |