mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
refactor(option.c): de-nest set_option_value
This commit is contained in:
@@ -2992,13 +2992,16 @@ char *set_option_value(const char *const name, const long number, const char *co
|
|||||||
int opt_idx = findoption(name);
|
int opt_idx = findoption(name);
|
||||||
if (opt_idx < 0) {
|
if (opt_idx < 0) {
|
||||||
semsg(_("E355: Unknown option: %s"), name);
|
semsg(_("E355: Unknown option: %s"), name);
|
||||||
} else {
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t flags = options[opt_idx].flags;
|
uint32_t flags = options[opt_idx].flags;
|
||||||
// Disallow changing some options in the sandbox
|
// Disallow changing some options in the sandbox
|
||||||
if (sandbox > 0 && (flags & P_SECURE)) {
|
if (sandbox > 0 && (flags & P_SECURE)) {
|
||||||
emsg(_(e_sandbox));
|
emsg(_(e_sandbox));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & P_STRING) {
|
if (flags & P_STRING) {
|
||||||
const char *s = string;
|
const char *s = string;
|
||||||
if (s == NULL || opt_flags & OPT_CLEAR) {
|
if (s == NULL || opt_flags & OPT_CLEAR) {
|
||||||
@@ -3008,7 +3011,11 @@ char *set_option_value(const char *const name, const long number, const char *co
|
|||||||
}
|
}
|
||||||
|
|
||||||
char_u *varp = (char_u *)get_varp_scope(&(options[opt_idx]), opt_flags);
|
char_u *varp = (char_u *)get_varp_scope(&(options[opt_idx]), opt_flags);
|
||||||
if (varp != NULL) { // hidden option is not changed
|
if (varp == NULL) {
|
||||||
|
// hidden option is not changed
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (number == 0 && string != NULL) {
|
if (number == 0 && string != NULL) {
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
@@ -3041,9 +3048,6 @@ char *set_option_value(const char *const name, const long number, const char *co
|
|||||||
return set_num_option(opt_idx, varp, numval, NULL, 0, opt_flags);
|
return set_num_option(opt_idx, varp, numval, NULL, 0, opt_flags);
|
||||||
}
|
}
|
||||||
return set_bool_option(opt_idx, varp, (int)numval, opt_flags);
|
return set_bool_option(opt_idx, varp, (int)numval, opt_flags);
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Call set_option_value() and when an error is returned report it.
|
/// Call set_option_value() and when an error is returned report it.
|
||||||
|
Reference in New Issue
Block a user