fix: make sure we have ran on_exit before returning is_done=true

This commit is contained in:
Folke Lemaitre 2022-11-29 07:56:59 +01:00
parent 5d84967e9c
commit 782d287d89
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 5 additions and 8 deletions

View File

@ -53,12 +53,7 @@ function Task:is_done()
end end
function Task:is_running() function Task:is_running()
for _, state in ipairs(self._running) do return self:has_started() and self._ended == nil
if state() then
return true
end
end
return false
end end
function Task:start() function Task:start()
@ -78,9 +73,11 @@ end
---@private ---@private
function Task:_check() function Task:_check()
if self:is_running() then for _, state in ipairs(self._running) do
if state() then
return return
end end
end
self._ended = vim.loop.hrtime() self._ended = vim.loop.hrtime()
if self._opts.on_done then if self._opts.on_done then
self._opts.on_done(self) self._opts.on_done(self)