aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-core/async
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2023-06-13 15:45:07 +0200
committerGitHub <noreply@github.com>2023-06-13 15:45:07 +0200
commitf5033463bb911a136e577fc6f339328f162e2b4a (patch)
tree79e7b65113b0f8e610b8cebeb8a2aeb654c8b728 /lua/mason-core/async
parentfix(command): run :MasonUpdate synchronously in headless mode (#1347) (diff)
downloadmason-f5033463bb911a136e577fc6f339328f162e2b4a.tar
mason-f5033463bb911a136e577fc6f339328f162e2b4a.tar.gz
mason-f5033463bb911a136e577fc6f339328f162e2b4a.tar.bz2
mason-f5033463bb911a136e577fc6f339328f162e2b4a.tar.lz
mason-f5033463bb911a136e577fc6f339328f162e2b4a.tar.xz
mason-f5033463bb911a136e577fc6f339328f162e2b4a.tar.zst
mason-f5033463bb911a136e577fc6f339328f162e2b4a.zip
fix(async): always check channel state (#1351)
Diffstat (limited to 'lua/mason-core/async')
-rw-r--r--lua/mason-core/async/init.lua13
1 files changed, 7 insertions, 6 deletions
diff --git a/lua/mason-core/async/init.lua b/lua/mason-core/async/init.lua
index 50c84a71..63d4ec94 100644
--- a/lua/mason-core/async/init.lua
+++ b/lua/mason-core/async/init.lua
@@ -176,13 +176,14 @@ local function wait(suspend_fns, mode)
for i, suspend_fn in ipairs(suspend_fns) do
thread_cancellations[i] = exports.run(suspend_fn, function(success, result)
completed = completed + 1
+ if channel:is_closed() then
+ return
+ end
if not success then
- if not channel:is_closed() then
- cancel()
- channel:send(false, result)
- results = nil
- thread_cancellations = {}
- end
+ cancel()
+ channel:send(false, result)
+ results = nil
+ thread_cancellations = {}
else
results[i] = result
if mode == "first" or completed >= count then