Skip to content

Commit c30b645

Browse files
Fix incompatibility with Neovim < 0.6 for Promise.
1 parent 8e7c156 commit c30b645

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lua/orgmode/utils/promise.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@
33
local PackedValue = {}
44
PackedValue.__index = PackedValue
55

6+
--- like {...} except preserve the lenght explicitly
7+
local function pack_len(...)
8+
return { n = select('#', ...), ... }
9+
end
10+
11+
--- like unpack() but use the length set by pack_len if present
12+
local function unpack_len(t)
13+
return unpack(t, 1, t.n)
14+
end
15+
616
function PackedValue.new(...)
7-
local values = vim.F.pack_len(...)
17+
local values = pack_len(...)
818
local tbl = { _values = values }
919
return setmetatable(tbl, PackedValue)
1020
end
@@ -17,7 +27,7 @@ function PackedValue.pcall(self, f)
1727
end
1828

1929
function PackedValue.unpack(self)
20-
return vim.F.unpack_len(self._values)
30+
return unpack_len(self._values)
2131
end
2232

2333
function PackedValue.first(self)

0 commit comments

Comments
 (0)