Skip to content

Commit b3457ef

Browse files
committed
fix: promise with nil arguments
1 parent 044c54b commit b3457ef

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lua/opencode/promise.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function Promise:finally(callback)
197197
-- Ignore callback errors and result, finally doesn't change the promise chain
198198
if not ok then
199199
-- Log error but don't propagate it
200-
vim.notify("Error in finally callback", vim.log.levels.WARN)
200+
vim.notify('Error in finally callback', vim.log.levels.WARN)
201201
end
202202
end
203203

@@ -374,9 +374,11 @@ end
374374
---@return fun(...): Promise<T>
375375
function Promise.async(fn)
376376
return function(...)
377+
-- Capture both args and count to handle nil values correctly
378+
local n = select('#', ...)
377379
local args = { ... }
378380
return Promise.spawn(function()
379-
return fn(unpack(args))
381+
return fn(unpack(args, 1, n))
380382
end)
381383
end
382384
end

0 commit comments

Comments
 (0)