@@ -704,7 +704,7 @@ M.delete = function(state, callback)
704704 fs_actions .delete_node (node .path , callback )
705705end
706706
707- --- @param callback function
707+ --- @param callback fun ( path : string )
708708--- @type neotree.TreeCommandVisual
709709M .delete_visual = function (state , selected_nodes , callback )
710710 local paths_to_delete = {}
@@ -725,6 +725,44 @@ M.delete_visual = function(state, selected_nodes, callback)
725725 fs_actions .delete_nodes (paths_to_delete , callback )
726726end
727727
728+ M .trash = function (state )
729+ local node = assert (state .tree :get_node ())
730+ if node .type ~= " file" and node .type ~= " directory" then
731+ log .warn (" The `trash` command can only be used on files and directories" )
732+ return
733+ end
734+ if node :get_depth () == 1 then
735+ log .error (
736+ " Will not trash root node "
737+ .. node .path
738+ .. " , please back out of the current directory if you want to trash the root node."
739+ )
740+ return
741+ end
742+ fs_actions .trash_node (node .path )
743+ end
744+
745+ --- @param callback fun ( path : string )
746+ --- @type neotree.TreeCommandVisual
747+ M .trash_visual = function (state , selected_nodes , callback )
748+ local paths_to_trash = {}
749+ for _ , node_to_trash in pairs (selected_nodes ) do
750+ if node_to_trash :get_depth () == 1 then
751+ log .error (
752+ " Will not trash root node "
753+ .. node_to_trash .path
754+ .. " , please back out of the current directory if you want to trash the root node."
755+ )
756+ return
757+ end
758+
759+ if node_to_trash .type == " file" or node_to_trash .type == " directory" then
760+ table.insert (paths_to_trash , node_to_trash .path )
761+ end
762+ end
763+ fs_actions .trash_nodes (paths_to_trash , callback )
764+ end
765+
728766M .preview = function (state )
729767 Preview .show (state )
730768end
0 commit comments