Change rename notification to indicate method used (git or fs)
parent
c7629620a5
commit
03c66101c9
|
|
@ -104,11 +104,15 @@ local function fileOp(op)
|
|||
end
|
||||
elseif op == "rename" or op == "move-rename" then
|
||||
rename.sendWillRenameToLsp(oldFilePath, newFilePath)
|
||||
local success = rename.moveFile(oldFilePath, newFilePath)
|
||||
local success, method = rename.moveFile(oldFilePath, newFilePath)
|
||||
if success then
|
||||
vim.cmd.edit(newFilePath)
|
||||
u.bwipeout("#")
|
||||
if method == "git" then
|
||||
u.notify(("Git renamed %q to %q."):format(oldName, newName))
|
||||
else
|
||||
u.notify(("Renamed %q to %q."):format(oldName, newName))
|
||||
end
|
||||
if lspSupportsRenaming then vim.cmd.wall() end
|
||||
end
|
||||
elseif op == "new" or op == "new-from-selection" then
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ function M.moveFile(oldFilePath, newFilePath)
|
|||
if isGitManagedFile(oldFilePath) then
|
||||
local renamed, git_mv_error = git_mv(oldFilePath, newFilePath)
|
||||
if renamed then
|
||||
return true
|
||||
return true, "git"
|
||||
else
|
||||
u.notify(
|
||||
("File managed by git.\nFailed to rename using git mv %q:\n%q\nAttempting to rename using fs."):format(
|
||||
|
|
@ -80,7 +80,7 @@ function M.moveFile(oldFilePath, newFilePath)
|
|||
end
|
||||
else
|
||||
local renamed, _ = vim.uv.fs_rename(oldFilePath, newFilePath)
|
||||
if renamed then return true end
|
||||
if renamed then return true, "fs" end
|
||||
end
|
||||
|
||||
---try `fs_copyfile` to support moving across partitions
|
||||
|
|
@ -88,7 +88,7 @@ function M.moveFile(oldFilePath, newFilePath)
|
|||
if copied then
|
||||
local deleted, deletedError = vim.uv.fs_unlink(oldFilePath)
|
||||
if deleted then
|
||||
return true
|
||||
return true, "fs"
|
||||
else
|
||||
u.notify(("Failed to delete %q: %q"):format(oldFilePath, deletedError), "error")
|
||||
return false
|
||||
|
|
|
|||
Loading…
Reference in New Issue