committed by
GitHub
parent
c18aa389a3
commit
72858986f9
@@ -45,11 +45,17 @@ function M.fn(node)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local err_msg = ""
|
||||||
|
local function on_stderr(_, data)
|
||||||
|
err_msg = err_msg .. (data and table.concat(data, " "))
|
||||||
|
end
|
||||||
|
|
||||||
-- trashes a path (file or folder)
|
-- trashes a path (file or folder)
|
||||||
local function trash_path(on_exit)
|
local function trash_path(on_exit)
|
||||||
vim.fn.jobstart(M.config.trash.cmd .. ' "' .. node.absolute_path .. '"', {
|
vim.fn.jobstart(M.config.trash.cmd .. ' "' .. node.absolute_path .. '"', {
|
||||||
detach = true,
|
detach = true,
|
||||||
on_exit = on_exit,
|
on_exit = on_exit,
|
||||||
|
on_stderr = on_stderr,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -69,14 +75,22 @@ function M.fn(node)
|
|||||||
-- trashing
|
-- trashing
|
||||||
if is_confirmed then
|
if is_confirmed then
|
||||||
if node.nodes ~= nil and not node.link_to then
|
if node.nodes ~= nil and not node.link_to then
|
||||||
trash_path(function()
|
trash_path(function(_, rc)
|
||||||
|
if rc ~= 0 then
|
||||||
|
utils.warn("trash failed: " .. err_msg .. "; please see :help nvim-tree.trash")
|
||||||
|
return
|
||||||
|
end
|
||||||
events._dispatch_folder_removed(node.absolute_path)
|
events._dispatch_folder_removed(node.absolute_path)
|
||||||
if M.enable_reload then
|
if M.enable_reload then
|
||||||
require("nvim-tree.actions.reloaders").reload_explorer()
|
require("nvim-tree.actions.reloaders").reload_explorer()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
trash_path(function()
|
trash_path(function(_, rc)
|
||||||
|
if rc ~= 0 then
|
||||||
|
utils.warn("trash failed: " .. err_msg .. "; please see :help nvim-tree.trash")
|
||||||
|
return
|
||||||
|
end
|
||||||
events._dispatch_file_removed(node.absolute_path)
|
events._dispatch_file_removed(node.absolute_path)
|
||||||
clear_buffer(node.absolute_path)
|
clear_buffer(node.absolute_path)
|
||||||
if M.enable_reload then
|
if M.enable_reload then
|
||||||
|
|||||||
Reference in New Issue
Block a user