mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +00:00
fix(api): check error after getting win/buf handle (#19052)
This commit is contained in:
@@ -43,6 +43,9 @@ static int validate_option_value_args(Dict(option) *opts, int *scope, int *opt_t
|
|||||||
if (opts->win.type == kObjectTypeInteger) {
|
if (opts->win.type == kObjectTypeInteger) {
|
||||||
*opt_type = SREQ_WIN;
|
*opt_type = SREQ_WIN;
|
||||||
*from = find_window_by_handle((int)opts->win.data.integer, err);
|
*from = find_window_by_handle((int)opts->win.data.integer, err);
|
||||||
|
if (ERROR_SET(err)) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
} else if (HAS_KEY(opts->win)) {
|
} else if (HAS_KEY(opts->win)) {
|
||||||
api_set_error(err, kErrorTypeValidation, "invalid value for key: win");
|
api_set_error(err, kErrorTypeValidation, "invalid value for key: win");
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -52,6 +55,9 @@ static int validate_option_value_args(Dict(option) *opts, int *scope, int *opt_t
|
|||||||
*scope = OPT_LOCAL;
|
*scope = OPT_LOCAL;
|
||||||
*opt_type = SREQ_BUF;
|
*opt_type = SREQ_BUF;
|
||||||
*from = find_buffer_by_handle((int)opts->buf.data.integer, err);
|
*from = find_buffer_by_handle((int)opts->buf.data.integer, err);
|
||||||
|
if (ERROR_SET(err)) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
} else if (HAS_KEY(opts->buf)) {
|
} else if (HAS_KEY(opts->buf)) {
|
||||||
api_set_error(err, kErrorTypeValidation, "invalid value for key: buf");
|
api_set_error(err, kErrorTypeValidation, "invalid value for key: buf");
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
@@ -1400,6 +1400,8 @@ describe('lua stdlib', function()
|
|||||||
pcall_err(exec_lua, 'return vim.bo.nosuchopt'))
|
pcall_err(exec_lua, 'return vim.bo.nosuchopt'))
|
||||||
matches("Expected lua string$",
|
matches("Expected lua string$",
|
||||||
pcall_err(exec_lua, 'return vim.bo[0][0].autoread'))
|
pcall_err(exec_lua, 'return vim.bo[0][0].autoread'))
|
||||||
|
matches("Invalid buffer id: %-1$",
|
||||||
|
pcall_err(exec_lua, 'return vim.bo[-1].filetype'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('vim.wo', function()
|
it('vim.wo', function()
|
||||||
@@ -1419,6 +1421,8 @@ describe('lua stdlib', function()
|
|||||||
pcall_err(exec_lua, 'return vim.wo.notanopt'))
|
pcall_err(exec_lua, 'return vim.wo.notanopt'))
|
||||||
matches("Expected lua string$",
|
matches("Expected lua string$",
|
||||||
pcall_err(exec_lua, 'return vim.wo[0][0].list'))
|
pcall_err(exec_lua, 'return vim.wo[0][0].list'))
|
||||||
|
matches("Invalid window id: %-1$",
|
||||||
|
pcall_err(exec_lua, 'return vim.wo[-1].list'))
|
||||||
eq(2, funcs.luaeval "vim.wo[1000].cole")
|
eq(2, funcs.luaeval "vim.wo[1000].cole")
|
||||||
exec_lua [[
|
exec_lua [[
|
||||||
vim.wo[1000].cole = 0
|
vim.wo[1000].cole = 0
|
||||||
|
Reference in New Issue
Block a user