mirror of
https://github.com/neovim/neovim.git
synced 2025-10-13 13:26:06 +00:00
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()`.
This commit is contained in:

committed by
Lewis Russell

parent
b2d471ab33
commit
9ae7d36ff5
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user