aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
diff options
context:
space:
mode:
authorJakob Schnitzer <mail@jakobschnitzer.de>2017-03-30 22:03:52 +0200
committerJustin M. Keyes <justinkz@gmail.com>2017-03-30 22:03:52 +0200
commiteb0e94f71b1f44cebf7ae5c1bcff348264af6cef (patch)
tree2d904e9a1409f24389a48bf4a31f9822301a3745 /src/nvim/option.c
parent66b336d89bd5b45e60587b3c1689c7435019d775 (diff)
downloadrneovim-eb0e94f71b1f44cebf7ae5c1bcff348264af6cef.tar.gz
rneovim-eb0e94f71b1f44cebf7ae5c1bcff348264af6cef.tar.bz2
rneovim-eb0e94f71b1f44cebf7ae5c1bcff348264af6cef.zip
api: {get,set}_option should {get,set} global value of local options (#6405)
- nvim_get_option should return the global default of a local option. - nvim_set_option should set the global default of a local option.
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r--src/nvim/option.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 9b31e14ea7..0bf81b4d3a 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -4619,14 +4619,13 @@ int get_option_value_strict(char *name,
}
char_u *varp = NULL;
- vimoption_T *p;
int rv = 0;
int opt_idx = findoption(name);
if (opt_idx < 0) {
return 0;
}
- p = &(options[opt_idx]);
+ vimoption_T *p = &options[opt_idx];
// Hidden option
if (p->var == NULL) {
@@ -4642,26 +4641,25 @@ int get_option_value_strict(char *name,
}
if (p->indir == PV_NONE) {
- if (opt_type == SREQ_GLOBAL)
+ if (opt_type == SREQ_GLOBAL) {
rv |= SOPT_GLOBAL;
- else
- return 0; // Did not request global-only option
+ } else {
+ return 0; // Did not request global-only option
+ }
} else {
if (p->indir & PV_BOTH) {
rv |= SOPT_GLOBAL;
- } else if (opt_type == SREQ_GLOBAL) {
- return 0; // Requested global option
}
if (p->indir & PV_WIN) {
if (opt_type == SREQ_BUF) {
- return 0; // Did not request window-local option
+ return 0; // Requested buffer-local, not window-local option
} else {
rv |= SOPT_WIN;
}
} else if (p->indir & PV_BUF) {
if (opt_type == SREQ_WIN) {
- return 0; // Did not request buffer-local option
+ return 0; // Requested window-local, not buffer-local option
} else {
rv |= SOPT_BUF;
}
@@ -4673,7 +4671,11 @@ int get_option_value_strict(char *name,
}
if (opt_type == SREQ_GLOBAL) {
- varp = p->var;
+ if (p->var == VAR_WIN) {
+ return 0;
+ } else {
+ varp = p->var;
+ }
} else {
if (opt_type == SREQ_BUF) {
// Special case: 'modified' is b_changed, but we also want to
@@ -4720,7 +4722,7 @@ int get_option_value_strict(char *name,
/// @param[in] name Option name.
/// @param[in] number New value for the number or boolean option.
/// @param[in] string New value for string option.
-/// @param[in] opt_flags Flags: OPT_LOCAL or 0 (both).
+/// @param[in] opt_flags Flags: OPT_LOCAL, OPT_GLOBAL, or 0 (both).
///
/// @return NULL on success, error message on error.
char *set_option_value(const char *const name, const long number,