neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 7fa7c758e28bbdeac1852737f0f84950b5a746a1
parent 12d065dcebc900a04264252244ba9138e5e5843a
Author: Lewis Russell <lewis6991@gmail.com>
Date:   Thu, 19 Jan 2023 10:34:54 +0000

refactor(optionstr.c): break up did_set_string_option 25

Diffstat:
Msrc/nvim/optionstr.c | 52++++++++++++++++++++++++++++------------------------
1 file changed, 28 insertions(+), 24 deletions(-)

diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c @@ -1247,6 +1247,32 @@ static void did_set_filetype(buf_T *buf, char **varp, int opt_flags, bool value_ } } +static void did_set_spelllang_source(win_T *win) +{ + char fname[200]; + char *q = win->w_s->b_p_spl; + + // Skip the first name if it is "cjk". + if (strncmp(q, "cjk,", 4) == 0) { + q += 4; + } + + // Source the spell/LANG.vim in 'runtimepath'. + // They could set 'spellcapcheck' depending on the language. + // Use the first name in 'spelllang' up to '_region' or + // '.encoding'. + char *p; + for (p = q; *p != NUL; p++) { + if (!ASCII_ISALNUM(*p) && *p != '-') { + break; + } + } + if (p > q) { + vim_snprintf(fname, sizeof(fname), "spell/%.*s.vim", (int)(p - q), q); + source_runtime(fname, DIP_ALL); + } +} + /// Handle string options that need some action to perform when changed. /// The new value must be allocated. /// @@ -1765,30 +1791,8 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf did_set_syntax(curbuf, value_changed); } else if (varp == &(curbuf->b_p_ft)) { did_set_filetype(curbuf, varp, opt_flags, value_changed); - } - if (varp == &(curwin->w_s->b_p_spl)) { - char fname[200]; - char *q = curwin->w_s->b_p_spl; - - // Skip the first name if it is "cjk". - if (strncmp(q, "cjk,", 4) == 0) { - q += 4; - } - - // Source the spell/LANG.vim in 'runtimepath'. - // They could set 'spellcapcheck' depending on the language. - // Use the first name in 'spelllang' up to '_region' or - // '.encoding'. - char *p; - for (p = q; *p != NUL; p++) { - if (!ASCII_ISALNUM(*p) && *p != '-') { - break; - } - } - if (p > q) { - vim_snprintf(fname, sizeof(fname), "spell/%.*s.vim", (int)(p - q), q); - source_runtime(fname, DIP_ALL); - } + } else if (varp == &(curwin->w_s->b_p_spl)) { + did_set_spelllang_source(curwin); } }