mirror of
https://github.com/neovim/neovim.git
synced 2026-02-17 09:04:19 +00:00
refactor(lua): use Arena when converting from lua stack to API args
and for return value of nlua_exec/nlua_call_ref, as this uses the same family of functions. NB: the handling of luaref:s is a bit of a mess. add api_luarefs_free_XX functions as a stop-gap as refactoring luarefs is a can of worms for another PR:s. as a minor feature/bug-fix, nvim_buf_call and nvim_win_call now preserves arbitrary return values.
This commit is contained in:
@@ -3543,6 +3543,18 @@ describe('lua stdlib', function()
|
||||
]])
|
||||
)
|
||||
end)
|
||||
|
||||
it('can return values by reference', function()
|
||||
eq(
|
||||
{ 4, 7 },
|
||||
exec_lua [[
|
||||
local val = {4, 10}
|
||||
local ref = vim.api.nvim_buf_call(0, function() return val end)
|
||||
ref[2] = 7
|
||||
return val
|
||||
]]
|
||||
)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('vim.api.nvim_win_call', function()
|
||||
@@ -3640,6 +3652,18 @@ describe('lua stdlib', function()
|
||||
|
|
||||
]]
|
||||
end)
|
||||
|
||||
it('can return values by reference', function()
|
||||
eq(
|
||||
{ 7, 10 },
|
||||
exec_lua [[
|
||||
local val = {4, 10}
|
||||
local ref = vim.api.nvim_win_call(0, function() return val end)
|
||||
ref[1] = 7
|
||||
return val
|
||||
]]
|
||||
)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('vim.iconv', function()
|
||||
|
||||
Reference in New Issue
Block a user