feat(picker.finder): added assertions that finder is still running when receiving results

This commit is contained in:
Folke Lemaitre 2025-10-22 08:40:02 +02:00
parent 0760abd293
commit a45503b957
No known key found for this signature in database
GPG key ID: 9B52594D560070AB

View file

@ -141,6 +141,8 @@ function M:run(picker)
return
end
local running = true
collectgarbage("stop") -- moar speed
---@cast finder snacks.picker.finder.async
---@diagnostic disable-next-line: await-in-sync
@ -151,6 +153,18 @@ function M:run(picker)
if #self.items >= limit then
return self.task:abort()
end
if not running then
Snacks.debug.backtrace({
"Finder yielded after done. This is a bug.",
("- aborted: `%s`"):format(self.task:aborted() or false),
"",
"# Backtrace",
}, {
level = vim.log.levels.ERROR,
title = "Snacks Picker Finder",
})
return
end
add(item)
picker.matcher.task:resume()
yield = yield or Async.yielder(YIELD_FIND)
@ -162,6 +176,7 @@ function M:run(picker)
picker.matcher.task:resume()
picker:update()
end
running = false
end)
end