aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-02-02 02:38:10 +0100
committerJustin M. Keyes <justinkz@gmail.com>2018-02-11 15:27:57 +0100
commite578d586f28160d684087bae99482ab3912d3770 (patch)
treef4e2319c9934728a45b2870feb7148e61f766ec2 /src/nvim/option.c
parentfd58863eb62edddf688a71d73448934efa188241 (diff)
downloadrneovim-e578d586f28160d684087bae99482ab3912d3770.tar.gz
rneovim-e578d586f28160d684087bae99482ab3912d3770.tar.bz2
rneovim-e578d586f28160d684087bae99482ab3912d3770.zip
vim-patch:8.0.0974: resetting a string option does not trigger OptionSet
Problem: Resetting a string option does not trigger OptionSet. (Rick Howe) Solution: Set the origval. https://github.com/vim/vim/commit/8efa026a25b95de5598535ef62505282a8584a4b
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r--src/nvim/option.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 6b1bb2b8a3..7195ef58ac 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -1515,6 +1515,16 @@ do_set (
/* The old value is kept until we are sure that the
* new value is valid. */
oldval = *(char_u **)varp;
+
+ // When setting the local value of a global
+ // option, the old value may be the global value.
+ if (((int)options[opt_idx].indir & PV_BOTH) && (opt_flags
+ & OPT_LOCAL)) {
+ origval = *(char_u **)get_varp(&options[opt_idx]);
+ } else {
+ origval = oldval;
+ }
+
if (nextchar == '&') { /* set to default val */
newval = options[opt_idx].def_val[
((flags & P_VI_DEF) || cp_val)
@@ -1610,15 +1620,6 @@ do_set (
++arg;
}
- /* When setting the local value of a global
- * option, the old value may be the global value. */
- if (((int)options[opt_idx].indir & PV_BOTH)
- && (opt_flags & OPT_LOCAL))
- origval = *(char_u **)get_varp(
- &options[opt_idx]);
- else
- origval = oldval;
-
/*
* Copy the new string into allocated memory.
* Can't use set_string_option_direct(), because
@@ -1788,7 +1789,7 @@ do_set (
new_value_alloced = TRUE;
}
- /* Set the new value. */
+ // Set the new value.
*(char_u **)(varp) = newval;
if (!starting && origval != NULL && newval != NULL) {
@@ -1807,15 +1808,18 @@ do_set (
errmsg = did_set_string_option(opt_idx, (char_u **)varp,
new_value_alloced, oldval, errbuf, opt_flags);
+ if (errmsg == NULL) {
+ trigger_optionsset_string(opt_idx, opt_flags, saved_origval,
+ saved_newval);
+ }
+ xfree(saved_origval);
+ xfree(saved_newval);
+
// If error detected, print the error message.
if (errmsg != NULL) {
- xfree(saved_origval);
- xfree(saved_newval);
goto skip;
}
- trigger_optionsset_string(opt_idx, opt_flags, saved_origval,
- saved_newval);
} else {
// key code option(FIXME(tarruda): Show a warning or something
// similar)
@@ -2407,8 +2411,12 @@ static char *set_string_option(const int opt_idx, const char *const value,
}
// call autocommand after handling side effects
- trigger_optionsset_string(opt_idx, opt_flags,
- saved_oldval, saved_newval);
+ if (r == NULL) {
+ trigger_optionsset_string(opt_idx, opt_flags,
+ saved_oldval, saved_newval);
+ }
+ xfree(saved_oldval);
+ xfree(saved_newval);
return r;
}
@@ -4458,8 +4466,6 @@ static void trigger_optionsset_string(int opt_idx, int opt_flags,
STRING_OBJ(cstr_as_string(newval)));
}
}
- xfree(oldval);
- xfree(newval);
}
/*