aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-01-19 10:33:22 +0000
committerLewis Russell <lewis6991@gmail.com>2023-01-25 11:48:52 +0000
commit3fbc5f9860c28d026fcd2864cf955e8899e0d589 (patch)
treeeb964b03ef9c08953a52395e7e0176ba9ecf85bf
parentccaed9447502046542e01a1a94816e9fbb0e475e (diff)
downloadrneovim-3fbc5f9860c28d026fcd2864cf955e8899e0d589.tar.gz
rneovim-3fbc5f9860c28d026fcd2864cf955e8899e0d589.tar.bz2
rneovim-3fbc5f9860c28d026fcd2864cf955e8899e0d589.zip
refactor(optionstr.c): break up did_set_string_option 23
-rw-r--r--src/nvim/optionstr.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index ab97c83b23..f18e7eb2f1 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -1205,6 +1205,20 @@ static void did_set_option_listflags(buf_T *buf, win_T *win, char **varp, char *
}
}
+// When 'syntax' is set, load the syntax of that name
+static void did_set_syntax(buf_T *buf, bool value_changed)
+{
+ static int syn_recursive = 0;
+
+ syn_recursive++;
+ // Only pass true for "force" when the value changed or not used
+ // recursively, to avoid endless recurrence.
+ apply_autocmds(EVENT_SYNTAX, buf->b_p_syn, buf->b_fname,
+ value_changed || syn_recursive == 1, buf);
+ buf->b_flags |= BF_SYN_SET;
+ syn_recursive--;
+}
+
/// Handle string options that need some action to perform when changed.
/// The new value must be allocated.
///
@@ -1719,17 +1733,8 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf
}
// Trigger the autocommand only after setting the flags.
- // When 'syntax' is set, load the syntax of that name
if (varp == &(curbuf->b_p_syn)) {
- static int syn_recursive = 0;
-
- syn_recursive++;
- // Only pass true for "force" when the value changed or not used
- // recursively, to avoid endless recurrence.
- apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname,
- value_changed || syn_recursive == 1, curbuf);
- curbuf->b_flags |= BF_SYN_SET;
- syn_recursive--;
+ did_set_syntax(curbuf, value_changed);
} else if (varp == &(curbuf->b_p_ft)) {
// 'filetype' is set, trigger the FileType autocommand
// Skip this when called from a modeline and the filetype was