aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-01-26 10:37:05 +0000
committerLewis Russell <lewis6991@gmail.com>2023-01-26 10:42:26 +0000
commit8f2d3537b49846f6e0d27ae5957b57a7ea57e232 (patch)
treef41c9adb6da2ca464c82ce1248faf9fd28437391
parent0170219e92ce211d935b78895825000f074c4cff (diff)
downloadrneovim-8f2d3537b49846f6e0d27ae5957b57a7ea57e232.tar.gz
rneovim-8f2d3537b49846f6e0d27ae5957b57a7ea57e232.tar.bz2
rneovim-8f2d3537b49846f6e0d27ae5957b57a7ea57e232.zip
refactor(option.c): add do_set_option_value
-rw-r--r--src/nvim/option.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 50ccf9d302..641f07d70b 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -1300,6 +1300,32 @@ static int validate_opt_idx(win_T *win, int opt_idx, int opt_flags, uint32_t fla
return OK;
}
+static void do_set_option_value(int opt_idx, int opt_flags, char **argp, int prefix, int nextchar,
+ int afterchar, set_op_T op, uint32_t flags, char *varp,
+ char *errbuf, size_t errbuflen, char **errmsg)
+{
+ int value_checked = false;
+ if (flags & P_BOOL) { // boolean
+ do_set_bool(opt_idx, opt_flags, prefix, nextchar, afterchar, varp, errmsg);
+ } else 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);
+ }
+}
+
static void do_set_option(int opt_flags, char **argp, bool *did_show, char *errbuf,
size_t errbuflen, char **errmsg)
{
@@ -1420,26 +1446,8 @@ static void do_set_option(int opt_flags, char **argp, bool *did_show, char *errb
return;
}
- int value_checked = false;
- if (flags & P_BOOL) { // boolean
- do_set_bool(opt_idx, opt_flags, prefix, nextchar, afterchar, varp, errmsg);
- } else 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);
- }
+ do_set_option_value(opt_idx, opt_flags, argp, prefix, nextchar, afterchar, op, flags, varp,
+ errbuf, errbuflen, errmsg);
}
/// Parse 'arg' for option settings.