@@ -121,8 +121,9 @@ local function do_copy(source, destination)
121121 end
122122
123123 local handle = luv .fs_scandir (source )
124+
124125 if type (handle ) == ' string' then
125- return api . nvim_err_writeln ( handle )
126+ return false , handle
126127 end
127128
128129 luv .fs_mkdir (destination , source_stats .mode )
@@ -133,13 +134,8 @@ local function do_copy(source, destination)
133134
134135 local new_name = source .. ' /' .. name
135136 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
143139 end
144140
145141 return true
@@ -173,10 +169,18 @@ local function do_paste(node, action_type, action_fn)
173169
174170 for _ , entry in ipairs (clip ) do
175171 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 )
177180 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 )
179182 end
183+ :: continue::
180184 end
181185 clipboard [action_type ] = {}
182186 return refresh_tree ()
0 commit comments