Description
Description
If you delete a directory in nvim tree that contain a symlink directory, deletion will fail and then the content inside the symlink actual directory is gone. the symlink itself is still there but the content are gone.
I try to delete the node_modules folder in one of my project within nvim tree trying to clean things up. One of the dependency in my project is a symlink to my local repo:
it looks like this:
| node-modules/
|--- deps-a -> /home/user/dev/deps-a
After that an error occur saying that the deletion of node_modules directory cannot be done, but when I go back to my deps-a directory, everything is gone, even .git is gone.
Neovim version
NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1713773202
Operating system and version
Nixos-24.11
Windows variant
No response
nvim-tree version
Clean room replication
-- no configuration is needed, default configuration will still cause the same issue so I just paste the original nvt-min.lua here
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvt-min/site]])
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
require("packer").startup({
{
"wbthomason/packer.nvim",
"nvim-tree/nvim-tree.lua",
"nvim-tree/nvim-web-devicons",
-- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
},
config = {
package_root = package_root,
compile_path = install_path .. "/plugin/packer_compiled.lua",
display = { non_interactive = true },
},
})
end
if vim.fn.isdirectory(install_path) == 0 then
print("Installing nvim-tree and dependencies.")
vim.fn.system({ "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path })
end
load_plugins()
require("packer").sync()
vim.cmd([[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]])
vim.opt.termguicolors = true
vim.opt.cursorline = true
-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
require("nvim-tree").setup({})
end
-- UNCOMMENT this block for diagnostics issues, substituting pattern and cmd as appropriate.
-- Requires diagnostics.enable = true in setup.
--[[
vim.api.nvim_create_autocmd("FileType", {
pattern = "lua",
callback = function()
vim.lsp.start {
name = "my-luals",
cmd = { "lua-language-server" },
root_dir = vim.loop.cwd(),
}
end,
})
]]
Steps to reproduce
mkdir testing && cd testing
mkdir first-dir
mkdir dir-to-delete && touch dir-to-delete/dont_delete_me
ln -s $(pwd)/dir-to-delete $(pwd)/first-dir/dir-symlink
nvim -nu /tmp/nvt-min.lua
:NvimTreeOpen
delete first-dir from nvim tree
the file inside dir-to-delete is gone, but the symlink is still there
Expected behavior
the symlink should be be deleted, along with the first-dir, if that is not possible, nothing should had been done. I don't expect it to go into the symlink and delete everything for me
Actual behavior
The content inside the original symlink directory gets deleted.
After trying to delete first-dir, the content inside the symlink is deleted