feat(event): add WillRenameNode (#1821)
This commit is contained in:
@@ -184,6 +184,7 @@ local function do_cut(source, destination)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
events._dispatch_will_rename_node(source, destination)
|
||||||
local success, errmsg = vim.loop.fs_rename(source, destination)
|
local success, errmsg = vim.loop.fs_rename(source, destination)
|
||||||
if not success then
|
if not success then
|
||||||
log.line("copy_paste", "do_cut fs_rename failed '%s'", errmsg)
|
log.line("copy_paste", "do_cut fs_rename failed '%s'", errmsg)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ function M.rename(node, to)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
events._dispatch_will_rename_node(node.absolute_path, to)
|
||||||
local success, err = vim.loop.fs_rename(node.absolute_path, to)
|
local success, err = vim.loop.fs_rename(node.absolute_path, to)
|
||||||
if not success then
|
if not success then
|
||||||
return notify.warn(err_fmt(node.absolute_path, to, err))
|
return notify.warn(err_fmt(node.absolute_path, to, err))
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ local global_handlers = {}
|
|||||||
|
|
||||||
M.Event = {
|
M.Event = {
|
||||||
Ready = "Ready",
|
Ready = "Ready",
|
||||||
|
WillRenameNode = "WillRenameNode",
|
||||||
NodeRenamed = "NodeRenamed",
|
NodeRenamed = "NodeRenamed",
|
||||||
TreeOpen = "TreeOpen",
|
TreeOpen = "TreeOpen",
|
||||||
TreeClose = "TreeClose",
|
TreeClose = "TreeClose",
|
||||||
@@ -40,6 +41,11 @@ function M._dispatch_ready()
|
|||||||
dispatch(M.Event.Ready)
|
dispatch(M.Event.Ready)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--@private
|
||||||
|
function M._dispatch_will_rename_node(old_name, new_name)
|
||||||
|
dispatch(M.Event.WillRenameNode, { old_name = old_name, new_name = new_name })
|
||||||
|
end
|
||||||
|
|
||||||
--@private
|
--@private
|
||||||
function M._dispatch_node_renamed(old_name, new_name)
|
function M._dispatch_node_renamed(old_name, new_name)
|
||||||
dispatch(M.Event.NodeRenamed, { old_name = old_name, new_name = new_name })
|
dispatch(M.Event.NodeRenamed, { old_name = old_name, new_name = new_name })
|
||||||
|
|||||||
Reference in New Issue
Block a user