nvim-tree / nvim-tree.lua

A file explorer tree for neovim written in lua
Other
7.18k stars 611 forks source link

After creating a directory, two folders are displayed. #2305

Closed noahxzhu closed 1 year ago

noahxzhu commented 1 year ago

Description

I've enabled the renderer.group_empty option. After I created a directory, two folders are displayed. This is only a visual issue.

https://github.com/nvim-tree/nvim-tree.lua/assets/8643866/b247ea16-bbdd-4f33-9ba7-2dd9b812cf1d

Neovim version

NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

macOS 13.4.1

nvim-tree version

4af572246ce49883e2a52c49203a19984454f2e0

Clean room replication

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({
        renderer = {
            group_empty = true,
        },
    })
end

Steps to reproduce

  1. nvim -nu nvt-min.lua directory_with_an_empty_folder_inside
  2. press "A" to create a directory at the same level with that empty folder
  3. move back to see what's the that folder

Expected behavior

No response

Actual behavior

No response

alex-courtis commented 1 year ago

Thanks for the detailed reproducer.

Confirmed, files and directories:

Refresh resolves the duplicate.

pritom-5 commented 1 year ago

Having this same problem since couple of days.

alex-courtis commented 1 year ago

Regression since 1fe3228

alex-courtis commented 1 year ago

This has surfaced an issue with grouped nodes:

Possible solution for the find file case: find and refresh the grouped parent when node is not present.

alex-courtis commented 1 year ago

@virezox @pritom-5 I'd be most grateful if you could test this branch. The tree structure will be properly updated following creation.

cd /path/to/nvim-tree.lua git pull git checkout 2305-grouped-extra-created-nodes

noahxzhu commented 1 year ago

As tested, this issue appears to have already been fixed.

alex-courtis commented 1 year ago

As tested, this issue appears to have already been fixed.

Many thanks. I'll soak that for a few more days.