From 6896d22b63ad12de4c4990d0eece4a9b6f9cd88f Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sat, 7 Aug 2021 21:17:45 +0200 Subject: fix(lua): preserve argument lists which are not lists --- runtime/lua/vim/F.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/F.lua b/runtime/lua/vim/F.lua index 09467eb8c6..1a258546a5 100644 --- a/runtime/lua/vim/F.lua +++ b/runtime/lua/vim/F.lua @@ -27,5 +27,14 @@ function F.nil_wrap(fn) end end +--- like {...} except preserve the lenght explicitly +function F.pack_len(...) + return {n=select('#', ...), ...} +end + +--- like unpack() but use the length set by F.pack_len if present +function F.unpack_len(t) + return unpack(t, 1, t.n) +end return F -- cgit