diff options
author | Famiu Haque <famiuhaque@proton.me> | 2024-10-29 03:21:33 +0600 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-11-02 15:53:49 +0000 |
commit | 86e54734bf9e05605d8b7146e7b0e79025138ba2 (patch) | |
tree | 3d59b1d7266f48cf869777c72c330fdaa87fba75 /src/nvim/option.c | |
parent | 3688a333544251c887d78e6501eec55f0fb685f8 (diff) | |
download | rneovim-86e54734bf9e05605d8b7146e7b0e79025138ba2.tar.gz rneovim-86e54734bf9e05605d8b7146e7b0e79025138ba2.tar.bz2 rneovim-86e54734bf9e05605d8b7146e7b0e79025138ba2.zip |
refactor(options): remove `get_option_value_strict`
Problem: `get_option_value_for` can perfectly replace `get_option_value_strict`, making the latter redundant.
Solution: Remove `get_option_value_strict`
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r-- | src/nvim/option.c | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index a8ec5b2919..a7e56d6d39 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3978,76 +3978,6 @@ int get_option_attrs(OptIndex opt_idx) return attrs; } -/// Check if option has a value in the requested scope. -/// -/// @param opt_idx Option index in options[] table. -/// @param req_scope Requested option scope. See OptReqScope in option.h. -/// -/// @return true if option has a value in the requested scope, false otherwise. -static bool option_has_scope(OptIndex opt_idx, OptReqScope req_scope) -{ - if (opt_idx == kOptInvalid) { - return false; - } - - vimoption_T *opt = get_option(opt_idx); - - // Hidden option. - if (opt->var == NULL) { - return false; - } - // TTY option. - if (is_tty_option(opt->fullname)) { - return req_scope == kOptReqGlobal; - } - - switch (req_scope) { - case kOptReqGlobal: - return opt->var != VAR_WIN; - case kOptReqBuf: - return opt->indir & PV_BUF; - case kOptReqWin: - return opt->indir & PV_WIN; - } - UNREACHABLE; -} - -/// Get the option value in the requested scope. -/// -/// @param opt_idx Option index in options[] table. -/// @param req_scope Requested option scope. See OptReqScope in option.h. -/// @param[in] from Pointer to buffer or window for local option value. -/// @param[out] err Error message, if any. -/// -/// @return Option value in the requested scope. Returns a Nil option value if option is not found, -/// hidden or if it isn't present in the requested scope. (i.e. has no global, window-local or -/// buffer-local value depending on opt_scope). -OptVal get_option_value_strict(OptIndex opt_idx, OptReqScope req_scope, void *from, Error *err) -{ - if (opt_idx == kOptInvalid || !option_has_scope(opt_idx, req_scope)) { - return NIL_OPTVAL; - } - - vimoption_T *opt = get_option(opt_idx); - switchwin_T switchwin; - aco_save_T aco; - void *ctx = req_scope == kOptReqWin ? (void *)&switchwin - : (req_scope == kOptReqBuf ? (void *)&aco : NULL); - bool switched = switch_option_context(ctx, req_scope, from, err); - if (ERROR_SET(err)) { - return NIL_OPTVAL; - } - - char *varp = get_varp_scope(opt, req_scope == kOptReqGlobal ? OPT_GLOBAL : OPT_LOCAL); - OptVal retv = optval_from_varp(opt_idx, varp); - - if (switched) { - restore_option_context(ctx, req_scope); - } - - return retv; -} - /// Get option value for buffer / window. /// /// @param opt_idx Option index in options[] table. |