From fca3053a3e5884f6eadc27e473661da2a87c353f Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 19 Jan 2023 10:30:00 +0000 Subject: [PATCH] refactor(optionstr.c): break up did_set_string_option 17 --- src/nvim/optionstr.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index c67494bf70..30c6d0ec91 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -1064,6 +1064,20 @@ static void did_set_completeopt(char **errmsg) } } +static void did_set_signcolumn(win_T *win, char **varp, const char *oldval, char **errmsg) +{ + if (check_signcolumn(*varp) != OK) { + *errmsg = e_invarg; + } + // When changing the 'signcolumn' to or from 'number', recompute the + // width of the number column if 'number' or 'relativenumber' is set. + if (((*oldval == 'n' && *(oldval + 1) == 'u') + || (*win->w_p_scl == 'n' && *(win->w_p_scl + 1) == 'u')) + && (win->w_p_nu || win->w_p_rnu)) { + win->w_nrwidth_line_count = 0; + } +} + /// Handle string options that need some action to perform when changed. /// The new value must be allocated. /// @@ -1346,16 +1360,7 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf } #endif } else if (varp == &curwin->w_p_scl) { // 'signcolumn' - if (check_signcolumn(*varp) != OK) { - errmsg = e_invarg; - } - // When changing the 'signcolumn' to or from 'number', recompute the - // width of the number column if 'number' or 'relativenumber' is set. - if (((*oldval == 'n' && *(oldval + 1) == 'u') - || (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) == 'u')) - && (curwin->w_p_nu || curwin->w_p_rnu)) { - curwin->w_nrwidth_line_count = 0; - } + did_set_signcolumn(curwin, varp, oldval, &errmsg); } else if (varp == &p_sloc) { // 'showcmdloc' if (check_opt_strings(p_sloc, p_sloc_values, false) != OK) { errmsg = e_invarg;