fix(picker.undo): use new API. Closes #707

This commit is contained in:
Folke Lemaitre 2025-01-23 07:53:33 +01:00
parent d673cbd5d1
commit 79a6eabd31
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -324,7 +324,7 @@ function M.spelling()
end
---@type snacks.picker.finder
function M.undo()
function M.undo(opts, ctx)
local tree = vim.fn.undotree()
local buf = vim.api.nvim_get_current_buf()
local win = vim.api.nvim_get_current_win()
@ -423,10 +423,9 @@ function M.undo()
-- Resolve the items in batches to prevent blocking the UI
---@param cb async fun(item: snacks.picker.finder.Item)
---@param task snacks.picker.Async
---@async
return function(cb, task)
task:on("abort", vim.schedule_wrap(restore))
return function(cb)
ctx.async:on("abort", vim.schedule_wrap(restore))
while #items > 0 do
vim.schedule(function()
@ -440,9 +439,9 @@ function M.undo()
if #items == 0 then
restore()
end
task:resume()
ctx.async:resume()
end)
task:suspend()
ctx.async:suspend()
end
end
end