@@ -12,6 +12,7 @@ local utils = require("neo-tree.utils")
12
12
local inputs = require (" neo-tree.ui.inputs" )
13
13
local events = require (" neo-tree.events" )
14
14
local log = require (" neo-tree.log" )
15
+ local Path = require (" plenary.path" )
15
16
16
17
local M = {}
17
18
94
95
95
96
-- Copy Node
96
97
M .copy_node = function (source , _destination , callback )
97
- local parent_path , name = utils .split_path (source )
98
+ local _ , name = utils .split_path (source )
98
99
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
105
111
vim .schedule (function ()
106
112
events .fire_event (events .FILE_ADDED , destination )
107
113
if callback then
108
114
callback (source , destination )
109
115
end
110
116
end )
111
- end )
112
117
end , ' Copy "' .. name .. ' " to:' )
113
118
end
114
119
0 commit comments