From 7dabb8b0f50a222adf72dd0fd4e19c415b94832a Mon Sep 17 00:00:00 2001 From: Chris Grieser <73286100+chrisgrieser@users.noreply.github.com> Date: Mon, 20 May 2024 23:20:29 +0200 Subject: [PATCH] fix(trashFile): use non-async process & fix buffer deletion --- lua/genghis/init.lua | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lua/genghis/init.lua b/lua/genghis/init.lua index f9cdfd7..a7e4086 100644 --- a/lua/genghis/init.lua +++ b/lua/genghis/init.lua @@ -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 --------------------------------------------------------------------------------