fix: renaming when buffer directory is not cwd

remotes/origin/HEAD
pseudometa 2023-03-17 11:53:34 +01:00
parent c75f852eb9
commit 383807b237
1 changed files with 2 additions and 1 deletions

View File

@ -24,6 +24,7 @@ end
local function fileOp(op)
local dir = expand("%:p:h")
local oldName = expand("%:t")
local oldFilePath = expand("%:p")
local oldNameNoExt = oldName:gsub("%.%w+$", "")
local oldExt = expand("%:e")
if oldExt ~= "" then oldExt = "." .. oldExt end
@ -99,7 +100,7 @@ local function fileOp(op)
cmd.edit(newFilePath)
vim.notify('Duplicated "' .. oldName .. '" as "' .. newName .. '".')
elseif op == "rename" or op == "move-rename" then
local success, errormsg = os.rename(oldName, newName)
local success, errormsg = os.rename(oldFilePath, newFilePath)
if success then
cmd.edit(newFilePath)
cmd.bwipeout("#")