feat(#2270): add notify.absolute_path - show file or absolute path (default) names with notifications (#2286)

Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
Asror
2023-06-24 23:06:21 -04:00
committed by GitHub
parent 7aff29d755
commit 3cc698b35b
7 changed files with 38 additions and 16 deletions

View File

@@ -20,17 +20,20 @@ local function err_fmt(from, to, reason)
end
function M.rename(node, to)
local notify_from = notify.render_path(node.absolute_path)
local notify_to = notify.render_path(to)
if utils.file_exists(to) then
notify.warn(err_fmt(node.absolute_path, to, "file already exists"))
notify.warn(err_fmt(notify_from, notify_to, "file already exists"))
return
end
events._dispatch_will_rename_node(node.absolute_path, to)
local success, err = vim.loop.fs_rename(node.absolute_path, to)
if not success then
return notify.warn(err_fmt(node.absolute_path, to, err))
return notify.warn(err_fmt(notify_from, notify_to, err))
end
notify.info(node.absolute_path .. " " .. to)
notify.info(notify_from .. " " .. notify_to)
utils.rename_loaded_buffers(node.absolute_path, to)
events._dispatch_node_renamed(node.absolute_path, to)
end