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