@@ -121,8 +121,9 @@ local function do_copy(source, destination)
121
121
end
122
122
123
123
local handle = luv .fs_scandir (source )
124
+
124
125
if type (handle ) == ' string' then
125
- return api . nvim_err_writeln ( handle )
126
+ return false , handle
126
127
end
127
128
128
129
luv .fs_mkdir (destination , source_stats .mode )
@@ -133,13 +134,8 @@ local function do_copy(source, destination)
133
134
134
135
local new_name = source .. ' /' .. name
135
136
local new_destination = destination .. ' /' .. name
136
- if t == ' directory' then
137
- local success = do_copy (new_name , new_destination )
138
- if not success then return false end
139
- else
140
- local success = luv .fs_copyfile (new_name , new_destination )
141
- if not success then return false end
142
- end
137
+ local success , msg = do_copy (new_name , new_destination )
138
+ if not success then return success , msg end
143
139
end
144
140
145
141
return true
@@ -173,10 +169,18 @@ local function do_paste(node, action_type, action_fn)
173
169
174
170
for _ , entry in ipairs (clip ) do
175
171
local dest = destination .. ' /' .. entry .name
176
- local success = action_fn (entry .absolute_path , dest )
172
+ local dest_stats = luv .fs_stat (dest )
173
+ if dest_stats then
174
+ local ans = vim .fn .input (dest .. ' already exists, overwrite ? y/n: ' )
175
+ clear_prompt ()
176
+ if not ans :match (' ^y' ) then goto continue end
177
+ end
178
+
179
+ local success , msg = action_fn (entry .absolute_path , dest )
177
180
if not success then
178
- api .nvim_err_writeln (' Could not ' .. action_type .. ' ' .. entry .absolute_path )
181
+ api .nvim_err_writeln (' Could not ' .. action_type .. ' ' .. entry .absolute_path .. ' - ' .. msg )
179
182
end
183
+ :: continue::
180
184
end
181
185
clipboard [action_type ] = {}
182
186
return refresh_tree ()
0 commit comments