mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
api/lua: make nvim_execute_lua use native lua floats, not special tables
Rationale: the purpose of nvim_execute_lua is to simply call lua code with lua values. If a lua function expects a floating point value, it should be enough to specify a float as argument to nvim_execute_lua. However, make sure to preserve the existing roundtripping behavior of API values when using `vim.api` functions. This is covered by existing lua/api_spec.lua tests.
This commit is contained in:
@@ -339,6 +339,15 @@ describe('API', function()
|
||||
"did\nthe\nfail"},
|
||||
meth_pcall(meths.execute_lua, 'error("did\\nthe\\nfail")', {}))
|
||||
end)
|
||||
|
||||
it('uses native float values', function()
|
||||
eq(2.5, meths.execute_lua("return select(1, ...)", {2.5}))
|
||||
eq("2.5", meths.execute_lua("return vim.inspect(...)", {2.5}))
|
||||
|
||||
-- "special" float values are still accepted as return values.
|
||||
eq(2.5, meths.execute_lua("return vim.api.nvim_eval('2.5')", {}))
|
||||
eq("{\n [false] = 2.5,\n [true] = 3\n}", meths.execute_lua("return vim.inspect(vim.api.nvim_eval('2.5'))", {}))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('nvim_input', function()
|
||||
|
||||
Reference in New Issue
Block a user