diff options
author | Famiu Haque <famiuhaque@proton.me> | 2024-11-25 15:07:56 +0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-25 17:07:56 +0800 |
commit | beec377e905baca73e772080c4f276c800ad2a40 (patch) | |
tree | 478d0eafce4ac8a7153fa66f39bfc70ba5d2adbc /src/nvim/eval.c | |
parent | 9e7b0bcf51924716461f838a33a9508b718934b5 (diff) | |
download | rneovim-beec377e905baca73e772080c4f276c800ad2a40.tar.gz rneovim-beec377e905baca73e772080c4f276c800ad2a40.tar.bz2 rneovim-beec377e905baca73e772080c4f276c800ad2a40.zip |
refactor(options): fix confusing naming of `scope` and `req_scope` (#31317)
Problem: The name `scope` is often used to refer to option flags because
`OPT_LOCAL` and `OPT_GLOBAL` are often used to determine the option
scope. This leads to the name `req_scope` being used for actual option
scopes instead.
Solution: Since the end-goal is to remove `OPT_LOCAL` and `OPT_GLOBAL`
entirely and replace them with `OptScope`, rename `OptScope` variables
to `scope` and the old scope flag variables to `opt_flags`.
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 35f0bde871..47f0a13b29 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -4114,10 +4114,10 @@ int eval_option(const char **const arg, typval_T *const rettv, const bool evalua { const bool working = (**arg == '+'); // has("+option") OptIndex opt_idx; - int scope; + int opt_flags; // Isolate the option name and find its value. - char *const option_end = (char *)find_option_var_end(arg, &opt_idx, &scope); + char *const option_end = (char *)find_option_var_end(arg, &opt_idx, &opt_flags); if (option_end == NULL) { if (rettv != NULL) { @@ -4145,7 +4145,7 @@ int eval_option(const char **const arg, typval_T *const rettv, const bool evalua ret = FAIL; } else if (rettv != NULL) { - OptVal value = is_tty_opt ? get_tty_option(*arg) : get_option_value(opt_idx, scope); + OptVal value = is_tty_opt ? get_tty_option(*arg) : get_option_value(opt_idx, opt_flags); assert(value.type != kOptValTypeNil); *rettv = optval_as_tv(value, true); @@ -7988,24 +7988,25 @@ void ex_execute(exarg_T *eap) /// Skip over the name of an option variable: "&option", "&g:option" or "&l:option". /// -/// @param[in,out] arg Points to the "&" or '+' when called, to "option" when returning. -/// @param[out] opt_idxp Set to option index in options[] table. -/// @param[out] scope Set to option scope. +/// @param[in,out] arg Points to the "&" or '+' when called, to "option" when returning. +/// @param[out] opt_idxp Set to option index in options[] table. +/// @param[out] opt_flags Option flags. /// /// @return NULL when no option name found. Otherwise pointer to the char after the option name. -const char *find_option_var_end(const char **const arg, OptIndex *const opt_idxp, int *const scope) +const char *find_option_var_end(const char **const arg, OptIndex *const opt_idxp, + int *const opt_flags) { const char *p = *arg; p++; if (*p == 'g' && p[1] == ':') { - *scope = OPT_GLOBAL; + *opt_flags = OPT_GLOBAL; p += 2; } else if (*p == 'l' && p[1] == ':') { - *scope = OPT_LOCAL; + *opt_flags = OPT_LOCAL; p += 2; } else { - *scope = 0; + *opt_flags = 0; } const char *end = find_option_end(p, opt_idxp); |