aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/vars.c
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@proton.me>2023-12-07 00:40:48 +0600
committerLewis Russell <me@lewisr.dev>2023-12-07 19:36:34 +0000
commit9ae7d36ff5ebaf75597b442e10890bd77df01fbe (patch)
tree7211492e2fea8e9b87336c3ea69f4c5b2c0b8702 /src/nvim/eval/vars.c
parentb2d471ab337e56f660eb7c89ae24f447f7b7a165 (diff)
downloadrneovim-9ae7d36ff5ebaf75597b442e10890bd77df01fbe.tar.gz
rneovim-9ae7d36ff5ebaf75597b442e10890bd77df01fbe.tar.bz2
rneovim-9ae7d36ff5ebaf75597b442e10890bd77df01fbe.zip
refactor(options): split `get_option_value()` into smaller functions
Problem: Currently, `get_option_value()` returns 3 separate things: The actual value of the option, whether the option is hidden, and the option flags. This makes the function difficult to refactor, modify or otherwise reason about. Solution: Split `get_option_value()` into 3 functions, each with a single purpose. This also affects `get_option_value_for()`.
Diffstat (limited to 'src/nvim/eval/vars.c')
-rw-r--r--src/nvim/eval/vars.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c
index 670ee39f4b..8864edbf69 100644
--- a/src/nvim/eval/vars.c
+++ b/src/nvim/eval/vars.c
@@ -773,11 +773,14 @@ static char *ex_let_option(char *arg, typval_T *const tv, const bool is_const,
const char c1 = *p;
*p = NUL;
- uint32_t opt_p_flags;
- bool hidden;
- OptVal curval = get_option_value(arg, &opt_p_flags, scope, &hidden);
+ bool is_tty_opt = is_tty_option(arg);
+ int opt_idx = is_tty_opt ? -1 : findoption(arg);
+ uint32_t opt_p_flags = get_option_flags(opt_idx);
+ bool hidden = is_option_hidden(opt_idx);
+ OptVal curval = is_tty_opt ? get_tty_option(arg) : get_option_value(opt_idx, scope);
OptVal newval = NIL_OPTVAL;
- if (curval.type == kOptValTypeNil && arg[0] != 't' && arg[1] != '_') {
+
+ if (curval.type == kOptValTypeNil) {
semsg(_(e_unknown_option2), arg);
goto theend;
}