mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
fix(picker.async): fixed aborting a coroutine from the coroutine itself. See #665
Some checks failed
CI / ci (push) Failing after 0s
Some checks failed
CI / ci (push) Failing after 0s
This commit is contained in:
parent
66d2854ea0
commit
c1e2c619b2
2 changed files with 4 additions and 2 deletions
|
@ -69,7 +69,6 @@ function M:run(picker)
|
|||
---@cast finder fun(cb:async fun(item:snacks.picker.finder.Item), task:snacks.picker.Async)
|
||||
---@diagnostic disable-next-line: await-in-sync
|
||||
self.task = Async.new(function()
|
||||
local async = Async.running()
|
||||
---@async
|
||||
finder(function(item)
|
||||
if #self.items >= limit then
|
||||
|
@ -83,7 +82,7 @@ function M:run(picker)
|
|||
picker.matcher.task:resume()
|
||||
yield = yield or Async.yielder(YIELD_FIND)
|
||||
yield()
|
||||
end, async)
|
||||
end, self.task)
|
||||
end):on("done", function()
|
||||
collectgarbage("restart")
|
||||
if not self.task:aborted() then
|
||||
|
|
|
@ -186,6 +186,9 @@ function Async:abort()
|
|||
return
|
||||
end
|
||||
self._aborted = true
|
||||
if coroutine.running() == self._co then
|
||||
error("aborted", 2)
|
||||
end
|
||||
coroutine.resume(self._co, "abort")
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue