mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 11:18:26 +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)
|
---@cast finder fun(cb:async fun(item:snacks.picker.finder.Item), task:snacks.picker.Async)
|
||||||
---@diagnostic disable-next-line: await-in-sync
|
---@diagnostic disable-next-line: await-in-sync
|
||||||
self.task = Async.new(function()
|
self.task = Async.new(function()
|
||||||
local async = Async.running()
|
|
||||||
---@async
|
---@async
|
||||||
finder(function(item)
|
finder(function(item)
|
||||||
if #self.items >= limit then
|
if #self.items >= limit then
|
||||||
|
@ -83,7 +82,7 @@ function M:run(picker)
|
||||||
picker.matcher.task:resume()
|
picker.matcher.task:resume()
|
||||||
yield = yield or Async.yielder(YIELD_FIND)
|
yield = yield or Async.yielder(YIELD_FIND)
|
||||||
yield()
|
yield()
|
||||||
end, async)
|
end, self.task)
|
||||||
end):on("done", function()
|
end):on("done", function()
|
||||||
collectgarbage("restart")
|
collectgarbage("restart")
|
||||||
if not self.task:aborted() then
|
if not self.task:aborted() then
|
||||||
|
|
|
@ -186,6 +186,9 @@ function Async:abort()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
self._aborted = true
|
self._aborted = true
|
||||||
|
if coroutine.running() == self._co then
|
||||||
|
error("aborted", 2)
|
||||||
|
end
|
||||||
coroutine.resume(self._co, "abort")
|
coroutine.resume(self._co, "abort")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue