diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-09-28 14:28:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-28 14:28:12 +0200 |
commit | 39652100558726ab5fec86153e09816b7e7bf7f5 (patch) | |
tree | 99686fac4689d460e99997c327bc7fba82a74c8f /src/nvim/eval/funcs.c | |
parent | 9ca313fb968448011aae0509e6552c52b9f8aa8c (diff) | |
parent | 4b7904d16b11915b16ea46b96f1ea6e28d87d5fd (diff) | |
download | rneovim-39652100558726ab5fec86153e09816b7e7bf7f5.tar.gz rneovim-39652100558726ab5fec86153e09816b7e7bf7f5.tar.bz2 rneovim-39652100558726ab5fec86153e09816b7e7bf7f5.zip |
Merge pull request #20375 from famiu/refactor/get_option
refactor: replace unnecessary helper functions in optionstr.c
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r-- | src/nvim/eval/funcs.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 9ba2ce2365..f2ef8e5cdd 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -1938,9 +1938,14 @@ static void f_exists(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) xfree(exp); } } else if (*p == '&' || *p == '+') { // Option. - n = (get_option_tv(&p, NULL, true) == OK); - if (*skipwhite(p) != NUL) { - n = false; // Trailing garbage. + 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; } } else if (*p == '*') { // Internal or user defined function. n = function_exists(p + 1, false); |