mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 11:18:26 +00:00
fix(picker.undo): use new API. Closes #707
This commit is contained in:
parent
d673cbd5d1
commit
79a6eabd31
1 changed files with 5 additions and 6 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue