add validation for file renaming

remotes/origin/HEAD
pseudometa 2022-11-27 08:47:52 +01:00
parent dfd996efe0
commit 3967e58533
1 changed files with 8 additions and 4 deletions

View File

@ -63,10 +63,14 @@ local function fileOp(op)
cmd {cmd = "edit", args = {filepath}}
vim.notify(" Duplicated '" .. oldName .. "' as '" .. newName .. "'. ")
elseif op == "rename" then
os.rename(oldName, newName)
cmd {cmd = "edit", args = {filepath}}
cmd("bdelete #")
vim.notify(" Renamed '" .. oldName .. "' to '" .. newName .. "'. ")
local success, errormsg = os.rename(oldName, newName)
if success then
cmd {cmd = "edit", args = {filepath}}
cmd("bdelete #")
vim.notify(" Renamed '" .. oldName .. "' to '" .. newName .. "'. ")
else
vim.notify(" Could not rename file: "..errormsg, error)
end
elseif op == "new" or op == "newFromSel" then
cmd {cmd = "edit", args = {filepath}}
if op == "newFromSel" then