diff options
author | dundargoc <gocdundar@gmail.com> | 2024-06-09 15:59:44 +0200 |
---|---|---|
committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2024-06-10 11:50:39 +0200 |
commit | 743c5808b616daece73145ddd12b39ae07bbd87a (patch) | |
tree | bd6b56d41e36912861b0e0da4f6be548d108555a | |
parent | 20f22f75ee629ae2db4cd99e730fa0af26553177 (diff) | |
download | rneovim-743c5808b616daece73145ddd12b39ae07bbd87a.tar.gz rneovim-743c5808b616daece73145ddd12b39ae07bbd87a.tar.bz2 rneovim-743c5808b616daece73145ddd12b39ae07bbd87a.zip |
fix(api): allow `scope = 'local'` with `buf` when using `nvim_get_option_value`
`nvim_get_option_value` throws a warning if both `scope` and `buf`
options are used at the same time. This is because using `buf` always
implies `scope` is local, and is therefore not needed. There's however
no need to error if `scope` is already set "local" as it's the correct
value.
-rw-r--r-- | src/nvim/api/options.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c index d9bc0ccc92..5adaff8449 100644 --- a/src/nvim/api/options.c +++ b/src/nvim/api/options.c @@ -54,6 +54,10 @@ static int validate_option_value_args(Dict(option) *opts, char *name, OptIndex * } if (HAS_KEY_X(opts, buf)) { + VALIDATE(!(HAS_KEY_X(opts, scope) && *scope == OPT_GLOBAL), "%s", + "cannot use both global 'scope' and 'buf'", { + return FAIL; + }); *scope = OPT_LOCAL; *req_scope = kOptReqBuf; *from = find_buffer_by_handle(opts->buf, err); @@ -68,11 +72,6 @@ static int validate_option_value_args(Dict(option) *opts, char *name, OptIndex * return FAIL; }); - VALIDATE((!HAS_KEY_X(opts, scope) || !HAS_KEY_X(opts, buf)), "%s", - "cannot use both 'scope' and 'buf'", { - return FAIL; - }); - VALIDATE((!HAS_KEY_X(opts, win) || !HAS_KEY_X(opts, buf)), "%s", "cannot use both 'buf' and 'win'", { return FAIL; |