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