diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-07-12 14:54:13 +0100 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2023-08-31 15:07:05 +0100 |
commit | 354a1154423fc381dfcd7b045963e8076288e777 (patch) | |
tree | 1078966e8673e5a20859acf48afd5fda8c0bcbfa | |
parent | 804c828e681ec3e55f19614d78c2b098b2672f86 (diff) | |
download | rneovim-354a1154423fc381dfcd7b045963e8076288e777.tar.gz rneovim-354a1154423fc381dfcd7b045963e8076288e777.tar.bz2 rneovim-354a1154423fc381dfcd7b045963e8076288e777.zip |
refactor(option.c): call did_set_option for all types
set_option_value() only called did_set_option() for string options,
whereas do_set_option_value() called it for all types.
This change makes set_option_value() call did_set_option() for all types
and thus makes it more consistent with do_set_option_value().
-rw-r--r-- | src/nvim/option.c | 10 | ||||
-rw-r--r-- | src/nvim/optionstr.c | 9 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index fb7c04d36b..e433dc5639 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1598,7 +1598,7 @@ int do_set(char *arg, int opt_flags) /// @param opt_flags possibly with OPT_MODELINE /// @param new_value value was replaced completely /// @param value_checked value was checked to be safe, no need to set P_INSECURE -void did_set_option(int opt_idx, int opt_flags, int new_value, int value_checked) +void did_set_option(int opt_idx, int opt_flags, bool new_value, bool value_checked) { options[opt_idx].flags |= P_WAS_SET; @@ -3793,6 +3793,8 @@ const char *set_option_value(const char *const name, const OptVal value, int opt goto end; } + int value_checked = false; + switch (v.type) { case kOptValTypeNil: abort(); // This will never happen. @@ -3825,11 +3827,15 @@ const char *set_option_value(const char *const name, const OptVal value, int opt if (s == NULL || opt_flags & OPT_CLEAR) { s = ""; } - errmsg = set_string_option(opt_idx, s, opt_flags, errbuf, sizeof(errbuf)); + errmsg = set_string_option(opt_idx, s, opt_flags, &value_checked, errbuf, sizeof(errbuf)); break; } } + if (errmsg != NULL) { + did_set_option(opt_idx, opt_flags, true, value_checked); + } + end: optval_free(v); // Free the copied OptVal. return errmsg; diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 9e5226a46f..d5ab47cc84 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -428,7 +428,7 @@ void set_string_option_direct_in_buf(buf_T *buf, const char *name, int opt_idx, /// /// @return NULL on success, an untranslated error message on error. const char *set_string_option(const int opt_idx, const char *const value, const int opt_flags, - char *const errbuf, const size_t errbuflen) + int *value_checked, char *const errbuf, const size_t errbuflen) FUNC_ATTR_NONNULL_ARG(2) FUNC_ATTR_WARN_UNUSED_RESULT { vimoption_T *opt = get_option(opt_idx); @@ -457,13 +457,8 @@ const char *set_string_option(const int opt_idx, const char *const value, const char *const saved_oldval_g = (oldval_g != NULL) ? xstrdup(oldval_g) : 0; char *const saved_newval = xstrdup(*varp); - int value_checked = false; const char *const errmsg = did_set_string_option(curbuf, curwin, opt_idx, varp, oldval, errbuf, - errbuflen, opt_flags, &value_checked); - if (errmsg == NULL) { - did_set_option(opt_idx, opt_flags, true, value_checked); - } - + errbuflen, opt_flags, value_checked); // call autocommand after handling side effects if (errmsg == NULL) { if (!starting) { |