aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-01-19 10:34:54 +0000
committerLewis Russell <lewis6991@gmail.com>2023-01-25 11:48:52 +0000
commit7fa7c758e28bbdeac1852737f0f84950b5a746a1 (patch)
tree5aac0ff195ccfca48180bee2ceb279406d393715
parent12d065dcebc900a04264252244ba9138e5e5843a (diff)
downloadrneovim-7fa7c758e28bbdeac1852737f0f84950b5a746a1.tar.gz
rneovim-7fa7c758e28bbdeac1852737f0f84950b5a746a1.tar.bz2
rneovim-7fa7c758e28bbdeac1852737f0f84950b5a746a1.zip
refactor(optionstr.c): break up did_set_string_option 25
-rw-r--r--src/nvim/optionstr.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index ccf2e7ce38..1da3f3f94a 100644
--- 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);
}
}