commit
a5d4a68f18
|
|
@ -192,7 +192,7 @@ function M.trashFile(opts)
|
||||||
-- Default trash locations
|
-- Default trash locations
|
||||||
if fn.has("linux") == 1 then
|
if fn.has("linux") == 1 then
|
||||||
local xdg_data = os.getenv("XDG_DATA_HOME")
|
local xdg_data = os.getenv("XDG_DATA_HOME")
|
||||||
trash = xdg_data and xdg_data .. "/trash/" or home .. "/.local/share/Trash/"
|
trash = xdg_data and xdg_data .. "/Trash/" or home .. "/.local/share/Trash/"
|
||||||
elseif fn.has("macunix") == 1 then
|
elseif fn.has("macunix") == 1 then
|
||||||
-- INFO macOS moves files to the icloud trash, if they are deleted from
|
-- INFO macOS moves files to the icloud trash, if they are deleted from
|
||||||
-- icloud folder, otherwise they go the user trash folder
|
-- icloud folder, otherwise they go the user trash folder
|
||||||
|
|
@ -210,9 +210,16 @@ function M.trashFile(opts)
|
||||||
if not (trash:find("/$")) then trash = trash .. "/" end -- append "/"
|
if not (trash:find("/$")) then trash = trash .. "/" end -- append "/"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fn.mkdir(trash, "p")
|
||||||
|
|
||||||
local currentFile = expand("%:p")
|
local currentFile = expand("%:p")
|
||||||
local filename = expand("%:t")
|
local filename = expand("%:t")
|
||||||
local success, errormsg = os.rename(currentFile, trash .. filename)
|
|
||||||
|
-- os.rename fails if trash is on different filesystem
|
||||||
|
local success, errormsg = pcall(cmd.write, trash .. filename)
|
||||||
|
if success then
|
||||||
|
success, errormsg = os.remove(currentFile)
|
||||||
|
end
|
||||||
|
|
||||||
if success then
|
if success then
|
||||||
bwipeout()
|
bwipeout()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue