From 3886617226511dc4d1cd4b65ecf14c043496af9d Mon Sep 17 00:00:00 2001 From: alexfinger21 Date: Tue, 22 Jul 2025 15:41:01 -0400 Subject: [PATCH 1/2] fix(#3077) deleting a directory containing symlink file will delete all content inside the symlink --- lua/nvim-tree/actions/fs/remove-file.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/nvim-tree/actions/fs/remove-file.lua b/lua/nvim-tree/actions/fs/remove-file.lua index fd71ae6a376..31bc16d1ea4 100644 --- a/lua/nvim-tree/actions/fs/remove-file.lua +++ b/lua/nvim-tree/actions/fs/remove-file.lua @@ -71,9 +71,14 @@ local function remove_dir(cwd) -- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility local stat = vim.loop.fs_stat(new_cwd) + ---@diagnostic disable-next-line: param-type-mismatch + local lstat = vim.loop.fs_lstat(new_cwd) + local type = stat and stat.type or nil + -- Checks if file is a link file to ensure deletion of the symlink instead of the file it points to + local ltype = lstat and lstat.type or nil - if type == "directory" then + if type == "directory" and ltype ~= "link" then local success = remove_dir(new_cwd) if not success then return false From 1487cd959e8324d59e3d0d4abbe771046c254763 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 28 Jul 2025 09:32:13 +1000 Subject: [PATCH 2/2] fix(#3077): add diagnostic override TODO --- lua/nvim-tree/actions/fs/remove-file.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/nvim-tree/actions/fs/remove-file.lua b/lua/nvim-tree/actions/fs/remove-file.lua index 31bc16d1ea4..b475506380a 100644 --- a/lua/nvim-tree/actions/fs/remove-file.lua +++ b/lua/nvim-tree/actions/fs/remove-file.lua @@ -71,6 +71,8 @@ local function remove_dir(cwd) -- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility local stat = vim.loop.fs_stat(new_cwd) + -- TODO remove once 0.12 is the minimum neovim version + -- path incorrectly specified as an integer, fixed upstream for neovim 0.12 https://github.com/neovim/neovim/pull/33872 ---@diagnostic disable-next-line: param-type-mismatch local lstat = vim.loop.fs_lstat(new_cwd)