Skip to content

Commit 3886617

Browse files
committed
fix(#3077) deleting a directory containing symlink file will delete all content inside the symlink
1 parent 543ed3c commit 3886617

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lua/nvim-tree/actions/fs/remove-file.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,14 @@ local function remove_dir(cwd)
7171

7272
-- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility
7373
local stat = vim.loop.fs_stat(new_cwd)
74+
---@diagnostic disable-next-line: param-type-mismatch
75+
local lstat = vim.loop.fs_lstat(new_cwd)
76+
7477
local type = stat and stat.type or nil
78+
-- Checks if file is a link file to ensure deletion of the symlink instead of the file it points to
79+
local ltype = lstat and lstat.type or nil
7580

76-
if type == "directory" then
81+
if type == "directory" and ltype ~= "link" then
7782
local success = remove_dir(new_cwd)
7883
if not success then
7984
return false

0 commit comments

Comments
 (0)