fix(trashFile): use non-async process & fix buffer deletion

remotes/origin/HEAD
Chris Grieser 2024-05-20 23:20:29 +02:00
parent 046a03a0a2
commit 7dabb8b0f5
1 changed files with 9 additions and 10 deletions

View File

@ -242,16 +242,15 @@ function M.trashFile(opts)
table.insert(trashArgs, oldFilePath)
cmd("silent! update")
vim.system(trashArgs, { detach = true }, function(out)
local oldName = vim.fs.basename(oldFilePath)
if out.code == 0 then
u.bwipeout()
u.notify(("%q deleted"):format(oldName))
else
local outmsg = out.stdout .. out.stderr
u.notify(("Trashing %q failed: " .. outmsg):format(oldName), "error")
end
end)
local oldName = vim.fs.basename(oldFilePath)
local result = vim.system(trashArgs):wait()
if result.code == 0 then
u.bwipeout()
u.notify(("%q deleted"):format(oldName))
else
local outmsg = (result.stdout or "") .. (result.stderr or "")
u.notify(("Trashing %q failed: " .. outmsg):format(oldName), "error")
end
end
--------------------------------------------------------------------------------