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