mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-19 21:06:46 +00:00
fix(task): run on_exit async. See #1569
This commit is contained in:
parent
461552474c
commit
60fe75c88d
3 changed files with 23 additions and 7 deletions
|
@ -217,16 +217,13 @@ function Task:spawn(cmd, opts)
|
|||
self._running:suspend()
|
||||
|
||||
local running = true
|
||||
local ret = true
|
||||
local ret = { ok = true, output = "" }
|
||||
---@param output string
|
||||
function opts.on_exit(ok, output)
|
||||
if not headless then
|
||||
self:log(vim.trim(output), ok and vim.log.levels.DEBUG or vim.log.levels.ERROR)
|
||||
end
|
||||
if on_exit then
|
||||
pcall(on_exit, ok, output)
|
||||
end
|
||||
ret = ok
|
||||
ret = { ok = ok, output = output }
|
||||
running = false
|
||||
self._running:resume()
|
||||
end
|
||||
|
@ -241,7 +238,11 @@ function Task:spawn(cmd, opts)
|
|||
Process.spawn(cmd, opts)
|
||||
coroutine.yield()
|
||||
assert(not running, "process still running?")
|
||||
return ret
|
||||
if on_exit then
|
||||
pcall(on_exit, ret.ok, ret.output)
|
||||
end
|
||||
coroutine.yield()
|
||||
return ret.ok
|
||||
end
|
||||
|
||||
function Task:prefix()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue