feat(trash): use vim.ui.select for confirmation

This commit is contained in:
kiyan
2022-07-18 14:25:52 +02:00
parent 1b667bc99e
commit 7cffe14743

View File

@@ -65,21 +65,7 @@ function M.fn(node)
})
end
local is_confirmed = true
-- confirmation prompt
if M.config.trash.require_confirm then
is_confirmed = false
print("Trash " .. node.name .. " ? y/n")
local ans = utils.get_user_input_char()
if ans:match "^y" then
is_confirmed = true
end
utils.clear_prompt()
end
-- trashing
if is_confirmed then
local function do_trash()
if node.nodes ~= nil and not node.link_to then
trash_path(function(_, rc)
if rc ~= 0 then
@@ -105,6 +91,16 @@ function M.fn(node)
end)
end
end
if M.config.trash.require_confirm then
vim.ui.select({ "y", "n" }, { prompt = "Trash " .. node.name .. " ?" }, function(choice)
if choice == "y" then
do_trash()
end
end)
else
do_trash()
end
end
function M.setup(opts)