From f6cc604af2a4d95ec9bcaa5bee705cec2e06d541 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 26 Feb 2022 13:27:43 +0000 Subject: fix(api): convert blob to NUL-terminated API string Looks like I did an oopsie; although API strings carry a size field, they should still be usable as C-strings! (even though they may contain embedded NULs) --- test/functional/lua/api_spec.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/functional/lua/api_spec.lua') diff --git a/test/functional/lua/api_spec.lua b/test/functional/lua/api_spec.lua index cb37fb9a1c..f173a15d32 100644 --- a/test/functional/lua/api_spec.lua +++ b/test/functional/lua/api_spec.lua @@ -102,6 +102,13 @@ describe('luaeval(vim.api.…)', function() eq(false, funcs.luaeval('vim.api.nvim__id(false)')) eq(NIL, funcs.luaeval('vim.api.nvim__id(nil)')) + -- API strings from Blobs can work as NUL-terminated C strings + eq('Vim(call):E5555: API call: Vim:E15: Invalid expression: ', + exc_exec('call nvim_eval(v:_null_blob)')) + eq('Vim(call):E5555: API call: Vim:E15: Invalid expression: ', + exc_exec('call nvim_eval(0z)')) + eq(1, eval('nvim_eval(0z31)')) + eq(0, eval([[type(luaeval('vim.api.nvim__id(1)'))]])) eq(1, eval([[type(luaeval('vim.api.nvim__id("1")'))]])) eq(3, eval([[type(luaeval('vim.api.nvim__id({1})'))]])) -- cgit