diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-01-26 09:47:50 +0000 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2023-01-26 10:02:01 +0000 |
commit | c6907ea895694ea675ba8c912c3d8e9f67f5c7d4 (patch) | |
tree | a84e6cc09b41963357cbc077b062806b9a426e86 | |
parent | e49ae04caf52ac848d090940a36393e4255726c8 (diff) | |
download | rneovim-c6907ea895694ea675ba8c912c3d8e9f67f5c7d4.tar.gz rneovim-c6907ea895694ea675ba8c912c3d8e9f67f5c7d4.tar.bz2 rneovim-c6907ea895694ea675ba8c912c3d8e9f67f5c7d4.zip |
refactor(option.c): de-nest code in do_set_option
-rw-r--r-- | src/nvim/option.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 4c83eb2a1a..1d5ceb70e6 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1405,35 +1405,36 @@ static void do_set_option(int opt_flags, char **argp, bool *did_show, char *errb if (nextchar != '?' && nextchar != NUL && !ascii_iswhite(afterchar)) { *errmsg = e_trailing; } - } else { - int value_checked = false; - if (flags & P_BOOL) { // boolean - do_set_bool(opt_idx, opt_flags, prefix, nextchar, afterchar, varp, errmsg); - } else { // Numeric or string. - if (vim_strchr("=:&<", nextchar) == NULL || prefix != 1) { - *errmsg = e_invarg; - return; - } - - if (flags & P_NUM) { // numeric - do_set_num(opt_idx, opt_flags, argp, nextchar, op, varp, errbuf, errbuflen, errmsg); - } else if (opt_idx >= 0) { // String. - do_set_string(opt_idx, opt_flags, argp, nextchar, op, flags, varp, errbuf, - errbuflen, &value_checked, errmsg); - } else { - // key code option(FIXME(tarruda): Show a warning or something - // similar) - } - } + return; + } - if (*errmsg != NULL) { + int value_checked = false; + if (flags & P_BOOL) { // boolean + do_set_bool(opt_idx, opt_flags, prefix, nextchar, afterchar, varp, errmsg); + } else { // Numeric or string. + if (vim_strchr("=:&<", nextchar) == NULL || prefix != 1) { + *errmsg = e_invarg; return; } - if (opt_idx >= 0) { - did_set_option(opt_idx, opt_flags, op == OP_NONE, value_checked); + if (flags & P_NUM) { // numeric + do_set_num(opt_idx, opt_flags, argp, nextchar, op, varp, errbuf, errbuflen, errmsg); + } else if (opt_idx >= 0) { // String. + do_set_string(opt_idx, opt_flags, argp, nextchar, op, flags, varp, errbuf, + errbuflen, &value_checked, errmsg); + } else { + // key code option(FIXME(tarruda): Show a warning or something + // similar) } } + + if (*errmsg != NULL) { + return; + } + + if (opt_idx >= 0) { + did_set_option(opt_idx, opt_flags, op == OP_NONE, value_checked); + } } /// Parse 'arg' for option settings. |