diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-01-23 11:13:20 +0000 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2023-01-25 11:48:53 +0000 |
commit | c6e7abb5834a9ced8c06f1d35e8989567c566f95 (patch) | |
tree | cfbcf323d286dcc51faf18e130257557e54ffec4 | |
parent | 6dac70bbfe843c442744d867d33931a92b10e253 (diff) | |
download | rneovim-c6e7abb5834a9ced8c06f1d35e8989567c566f95.tar.gz rneovim-c6e7abb5834a9ced8c06f1d35e8989567c566f95.tar.bz2 rneovim-c6e7abb5834a9ced8c06f1d35e8989567c566f95.zip |
refactor(optionstr.c): break up did_set_string_option 50
-rw-r--r-- | src/nvim/optionstr.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 1400b9652c..21f1170498 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -1520,6 +1520,20 @@ static void did_set_virtualedit(win_T *win, int opt_flags, char *oldval, char ** } } +static void did_set_lispoptions(char **varp, char **errmsg) +{ + if (**varp != NUL && strcmp(*varp, "expr:0") != 0 && strcmp(*varp, "expr:1") != 0) { + *errmsg = e_invarg; + } +} + +static void did_set_inccommand(char **errmsg) +{ + if (check_opt_strings(p_icm, p_icm_values, false) != OK) { + *errmsg = e_invarg; + } +} + static void did_set_filetype_or_syntax(char **varp, char *oldval, int *value_checked, bool *value_changed, char **errmsg) { @@ -1535,6 +1549,20 @@ static void did_set_filetype_or_syntax(char **varp, char *oldval, int *value_che *value_checked = true; } +static void did_set_winhl(win_T *win, char **errmsg) +{ + if (!parse_winhl_opt(win)) { + *errmsg = e_invarg; + } +} + +static void did_set_termpastefilter(char **errmsg) +{ + if (opt_strings_flags(p_tpf, p_tpf_values, &tpf_flags, true) != OK) { + *errmsg = e_invarg; + } +} + static void did_set_optexpr(buf_T *buf, win_T *win, char **varp, char **gvarp) { char **p_opt = NULL; @@ -1885,23 +1913,15 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf // TODO(vim): recognize errors parse_cino(curbuf); } else if (gvarp == &p_lop) { // 'lispoptions' - if (**varp != NUL && strcmp(*varp, "expr:0") != 0 && strcmp(*varp, "expr:1") != 0) { - errmsg = e_invarg; - } + did_set_lispoptions(varp, &errmsg); } else if (varp == &p_icm) { // 'inccommand' - if (check_opt_strings(p_icm, p_icm_values, false) != OK) { - errmsg = e_invarg; - } + did_set_inccommand(&errmsg); } else if (gvarp == &p_ft || gvarp == &p_syn) { did_set_filetype_or_syntax(varp, oldval, value_checked, &value_changed, &errmsg); } else if (varp == &curwin->w_p_winhl) { - if (!parse_winhl_opt(curwin)) { - errmsg = e_invarg; - } + did_set_winhl(curwin, &errmsg); } else if (varp == &p_tpf) { - if (opt_strings_flags(p_tpf, p_tpf_values, &tpf_flags, true) != OK) { - errmsg = e_invarg; - } + did_set_termpastefilter(&errmsg); } else if (varp == &(curbuf->b_p_vsts)) { // 'varsofttabstop' char *cp; |