@@ -12,6 +12,7 @@ local utils = require("neo-tree.utils")
1212local inputs = require (" neo-tree.ui.inputs" )
1313local events = require (" neo-tree.events" )
1414local log = require (" neo-tree.log" )
15+ local Path = require (" plenary.path" )
1516
1617local M = {}
1718
9495
9596-- Copy Node
9697M .copy_node = function (source , _destination , callback )
97- local parent_path , name = utils .split_path (source )
98+ local _ , name = utils .split_path (source )
9899 get_unused_name (_destination or source , function (destination )
99- create_all_parents (destination )
100- loop .fs_copyfile (source , destination , function (err )
101- if err then
102- log .error (" Could not copy the files from" , source , " to" , destination , " :" , err )
103- return
104- end
100+ local path = Path :new (source )
101+ local success , result = pcall (path .copy , path , {
102+ destination = destination ,
103+ recursive = true ,
104+ parents = true ,
105+ })
106+
107+ if not success then
108+ log .error (" Could not copy the files from" , source , " to" , destination , " :" , result )
109+ return
110+ end
105111 vim .schedule (function ()
106112 events .fire_event (events .FILE_ADDED , destination )
107113 if callback then
108114 callback (source , destination )
109115 end
110116 end )
111- end )
112117 end , ' Copy "' .. name .. ' " to:' )
113118end
114119
0 commit comments