mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
refactor(optionstr.c): break up did_set_string_option 5
This commit is contained in:
@@ -704,6 +704,29 @@ static void did_set_helplang(char **errmsg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void did_set_background(char **errmsg)
|
||||||
|
{
|
||||||
|
if (check_opt_strings(p_bg, p_bg_values, false) != OK) {
|
||||||
|
*errmsg = e_invarg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dark = (*p_bg == 'd');
|
||||||
|
|
||||||
|
init_highlight(false, false);
|
||||||
|
|
||||||
|
if (dark != (*p_bg == 'd') && get_var_value("g:colors_name") != NULL) {
|
||||||
|
// The color scheme must have set 'background' back to another
|
||||||
|
// value, that's not what we want here. Disable the color
|
||||||
|
// scheme and set the colors again.
|
||||||
|
do_unlet(S_LEN("g:colors_name"), true);
|
||||||
|
free_string_option(p_bg);
|
||||||
|
p_bg = xstrdup((dark ? "dark" : "light"));
|
||||||
|
check_string_option(&p_bg);
|
||||||
|
init_highlight(false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Handle string options that need some action to perform when changed.
|
/// Handle string options that need some action to perform when changed.
|
||||||
/// The new value must be allocated.
|
/// The new value must be allocated.
|
||||||
///
|
///
|
||||||
@@ -814,24 +837,7 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf
|
|||||||
errmsg = check_chars_options();
|
errmsg = check_chars_options();
|
||||||
}
|
}
|
||||||
} else if (varp == &p_bg) { // 'background'
|
} else if (varp == &p_bg) { // 'background'
|
||||||
if (check_opt_strings(p_bg, p_bg_values, false) == OK) {
|
did_set_background(&errmsg);
|
||||||
int dark = (*p_bg == 'd');
|
|
||||||
|
|
||||||
init_highlight(false, false);
|
|
||||||
|
|
||||||
if (dark != (*p_bg == 'd') && get_var_value("g:colors_name") != NULL) {
|
|
||||||
// The color scheme must have set 'background' back to another
|
|
||||||
// value, that's not what we want here. Disable the color
|
|
||||||
// scheme and set the colors again.
|
|
||||||
do_unlet(S_LEN("g:colors_name"), true);
|
|
||||||
free_string_option(p_bg);
|
|
||||||
p_bg = xstrdup((dark ? "dark" : "light"));
|
|
||||||
check_string_option(&p_bg);
|
|
||||||
init_highlight(false, false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
errmsg = e_invarg;
|
|
||||||
}
|
|
||||||
} else if (varp == &p_wim) { // 'wildmode'
|
} else if (varp == &p_wim) { // 'wildmode'
|
||||||
if (check_opt_wim() == FAIL) {
|
if (check_opt_wim() == FAIL) {
|
||||||
errmsg = e_invarg;
|
errmsg = e_invarg;
|
||||||
|
Reference in New Issue
Block a user