diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-01-19 10:30:49 +0000 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2023-01-25 11:48:52 +0000 |
commit | c2fa39e02629a26f0546642d6d283faa1e4c1382 (patch) | |
tree | a2dd261095a394c22edf0306d103a0428c97ea65 | |
parent | fec41d5f1526610a02811d0035ce7279772203e7 (diff) | |
download | rneovim-c2fa39e02629a26f0546642d6d283faa1e4c1382.tar.gz rneovim-c2fa39e02629a26f0546642d6d283faa1e4c1382.tar.bz2 rneovim-c2fa39e02629a26f0546642d6d283faa1e4c1382.zip |
refactor(optionstr.c): break up did_set_string_option 19
-rw-r--r-- | src/nvim/optionstr.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 78187caf24..19fa24a662 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -1094,6 +1094,28 @@ static void did_set_pastetoggle(void) } } +static void did_set_tagcase(buf_T *buf, int opt_flags, char **errmsg) +{ + unsigned int *flags; + char *p; + + if (opt_flags & OPT_LOCAL) { + p = buf->b_p_tc; + flags = &buf->b_tc_flags; + } else { + p = p_tc; + flags = &tc_flags; + } + + if ((opt_flags & OPT_LOCAL) && *p == NUL) { + // make the local value empty: use the global value + *flags = 0; + } else if (*p == NUL + || opt_strings_flags(p, p_tc_values, flags, false) != OK) { + *errmsg = e_invarg; + } +} + /// Handle string options that need some action to perform when changed. /// The new value must be allocated. /// @@ -1402,24 +1424,7 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf errmsg = e_invarg; } } else if (gvarp == &p_tc) { // 'tagcase' - unsigned int *flags; - char *p; - - if (opt_flags & OPT_LOCAL) { - p = curbuf->b_p_tc; - flags = &curbuf->b_tc_flags; - } else { - p = p_tc; - flags = &tc_flags; - } - - if ((opt_flags & OPT_LOCAL) && *p == NUL) { - // make the local value empty: use the global value - *flags = 0; - } else if (*p == NUL - || opt_strings_flags(p, p_tc_values, flags, false) != OK) { - errmsg = e_invarg; - } + did_set_tagcase(curbuf, opt_flags, &errmsg); } else if (varp == &p_cmp) { // 'casemap' if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, true) != OK) { errmsg = e_invarg; |