aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-01-23 09:59:11 +0000
committerLewis Russell <lewis6991@gmail.com>2023-01-25 11:48:52 +0000
commit5024ac8eb55b7d63df7f70e51efccf2830262a99 (patch)
treec92f2bca142bf81aac28c2251efaf974bb63e871 /src
parent655292586a6d3e99810ddf16d145d984d040a8c8 (diff)
downloadrneovim-5024ac8eb55b7d63df7f70e51efccf2830262a99.tar.gz
rneovim-5024ac8eb55b7d63df7f70e51efccf2830262a99.tar.bz2
rneovim-5024ac8eb55b7d63df7f70e51efccf2830262a99.zip
refactor(optionstr.c): break up did_set_string_option 29
Diffstat (limited to 'src')
-rw-r--r--src/nvim/optionstr.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index fbb34e0735..48e4f2c6b2 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -1165,6 +1165,21 @@ static void did_set_virtualedit(win_T *win, int opt_flags, char *oldval, char **
}
}
+static void did_set_syntax(char **varp, char *oldval, int *value_checked, bool *value_changed,
+ char **errmsg)
+{
+ if (!valid_filetype(*varp)) {
+ *errmsg = e_invarg;
+ return;
+ }
+
+ *value_changed = strcmp(oldval, *varp) != 0;
+
+ // Since we check the value, there is no need to set P_INSECURE,
+ // even when the value comes from a modeline.
+ *value_checked = true;
+}
+
static void did_set_optexpr(buf_T *buf, win_T *win, char **varp, char **gvarp)
{
char **p_opt = NULL;
@@ -1230,7 +1245,7 @@ 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 void do_syntax_autocmd(buf_T *buf, bool value_changed)
{
static int syn_recursive = 0;
@@ -1243,7 +1258,7 @@ static void did_set_syntax(buf_T *buf, bool value_changed)
syn_recursive--;
}
-static void did_set_filetype(buf_T *buf, char **varp, int opt_flags, bool value_changed)
+static void do_filetype_autocmd(buf_T *buf, char **varp, int opt_flags, bool value_changed)
{
// 'filetype' is set, trigger the FileType autocommand
// Skip this when called from a modeline and the filetype was
@@ -1660,15 +1675,7 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf
*value_checked = true;
}
} else if (gvarp == &p_syn) {
- if (!valid_filetype(*varp)) {
- errmsg = e_invarg;
- } else {
- value_changed = strcmp(oldval, *varp) != 0;
-
- // Since we check the value, there is no need to set P_INSECURE,
- // even when the value comes from a modeline.
- *value_checked = true;
- }
+ did_set_syntax(varp, oldval, value_checked, &value_changed, &errmsg);
} else if (varp == &curwin->w_p_winhl) {
if (!parse_winhl_opt(curwin)) {
errmsg = e_invarg;
@@ -1787,9 +1794,9 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf
// Trigger the autocommand only after setting the flags.
if (varp == &(curbuf->b_p_syn)) {
- did_set_syntax(curbuf, value_changed);
+ do_syntax_autocmd(curbuf, value_changed);
} else if (varp == &(curbuf->b_p_ft)) {
- did_set_filetype(curbuf, varp, opt_flags, value_changed);
+ do_filetype_autocmd(curbuf, varp, opt_flags, value_changed);
} else if (varp == &(curwin->w_s->b_p_spl)) {
did_set_spelllang_source(curwin);
}