mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
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.
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user