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) table.insert(trashArgs, oldFilePath)
cmd("silent! update") cmd("silent! update")
vim.system(trashArgs, { detach = true }, function(out) local oldName = vim.fs.basename(oldFilePath)
local oldName = vim.fs.basename(oldFilePath) local result = vim.system(trashArgs):wait()
if out.code == 0 then if result.code == 0 then
u.bwipeout() u.bwipeout()
u.notify(("%q deleted"):format(oldName)) u.notify(("%q deleted"):format(oldName))
else else
local outmsg = out.stdout .. out.stderr local outmsg = (result.stdout or "") .. (result.stderr or "")
u.notify(("Trashing %q failed: " .. outmsg):format(oldName), "error") u.notify(("Trashing %q failed: " .. outmsg):format(oldName), "error")
end end
end)
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------