aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/deprecated.c
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@proton.me>2024-11-25 15:07:56 +0600
committerGitHub <noreply@github.com>2024-11-25 17:07:56 +0800
commitbeec377e905baca73e772080c4f276c800ad2a40 (patch)
tree478d0eafce4ac8a7153fa66f39bfc70ba5d2adbc /src/nvim/api/deprecated.c
parent9e7b0bcf51924716461f838a33a9508b718934b5 (diff)
downloadrneovim-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/api/deprecated.c')
-rw-r--r--src/nvim/api/deprecated.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c
index b38a7d4173..493856905f 100644
--- a/src/nvim/api/deprecated.c
+++ b/src/nvim/api/deprecated.c
@@ -636,12 +636,12 @@ void nvim_win_set_option(uint64_t channel_id, Window window, String name, Object
/// Gets the value of a global or local (buffer, window) option.
///
/// @param[in] from Pointer to buffer or window for local option value.
-/// @param req_scope Requested option scope. See OptScope in option.h.
+/// @param scope Option scope. See OptScope in option.h.
/// @param name The option name.
/// @param[out] err Details of an error that may have occurred.
///
/// @return the option value.
-static Object get_option_from(void *from, OptScope req_scope, String name, Error *err)
+static Object get_option_from(void *from, OptScope scope, String name, Error *err)
{
VALIDATE_S(name.size > 0, "option name", "<empty>", {
return (Object)OBJECT_INIT;
@@ -650,9 +650,9 @@ static Object get_option_from(void *from, OptScope req_scope, String name, Error
OptIndex opt_idx = find_option(name.data);
OptVal value = NIL_OPTVAL;
- if (option_has_scope(opt_idx, req_scope)) {
- value = get_option_value_for(opt_idx, req_scope == kOptScopeGlobal ? OPT_GLOBAL : OPT_LOCAL,
- req_scope, from, err);
+ if (option_has_scope(opt_idx, scope)) {
+ value = get_option_value_for(opt_idx, scope == kOptScopeGlobal ? OPT_GLOBAL : OPT_LOCAL,
+ scope, from, err);
if (ERROR_SET(err)) {
return (Object)OBJECT_INIT;
}
@@ -668,12 +668,12 @@ static Object get_option_from(void *from, OptScope req_scope, String name, Error
/// Sets the value of a global or local (buffer, window) option.
///
/// @param[in] to Pointer to buffer or window for local option value.
-/// @param req_scope Requested option scope. See OptScope in option.h.
+/// @param scope Option scope. See OptScope in option.h.
/// @param name The option name.
/// @param value New option value.
/// @param[out] err Details of an error that may have occurred.
-static void set_option_to(uint64_t channel_id, void *to, OptScope req_scope, String name,
- Object value, Error *err)
+static void set_option_to(uint64_t channel_id, void *to, OptScope scope, String name, Object value,
+ Error *err)
{
VALIDATE_S(name.size > 0, "option name", "<empty>", {
return;
@@ -698,12 +698,12 @@ static void set_option_to(uint64_t channel_id, void *to, OptScope req_scope, Str
// For global-win-local options -> setlocal
// For win-local options -> setglobal and setlocal (opt_flags == 0)
const int opt_flags
- = (req_scope == kOptScopeWin && !option_has_scope(opt_idx, kOptScopeGlobal))
+ = (scope == kOptScopeWin && !option_has_scope(opt_idx, kOptScopeGlobal))
? 0
- : ((req_scope == kOptScopeGlobal) ? OPT_GLOBAL : OPT_LOCAL);
+ : ((scope == kOptScopeGlobal) ? OPT_GLOBAL : OPT_LOCAL);
WITH_SCRIPT_CONTEXT(channel_id, {
- set_option_value_for(name.data, opt_idx, optval, opt_flags, req_scope, to, err);
+ set_option_value_for(name.data, opt_idx, optval, opt_flags, scope, to, err);
});
}