Skip to content

Commit 2458cb7

Browse files
authored
fix(filesystem): prevent infinite recursion by copying folder to itself, fixes #795 (#801)
1 parent 9e42a88 commit 2458cb7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lua/neo-tree/sources/filesystem/lib/fs_actions.lua

+5
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ end
224224
M.copy_node = function(source, _destination, callback, using_root_directory)
225225
local _, name = utils.split_path(source)
226226
get_unused_name(_destination or source, using_root_directory, function(destination)
227+
local parent_path, _ = utils.split_path(destination)
228+
if source == parent_path then
229+
log.warn("Cannot copy a file/folder to itself")
230+
return
231+
end
227232
local source_path = Path:new(source)
228233
if source_path:is_file() then
229234
-- When the source is a file, then Path.copy() currently doesn't create

0 commit comments

Comments
 (0)