Skip to content

group empty directories #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cseickel opened this issue Mar 27, 2022 · 11 comments
Closed

group empty directories #216

cseickel opened this issue Mar 27, 2022 · 11 comments
Labels
enhancement New feature or request

Comments

@cseickel
Copy link
Contributor

[ ] group empty directories (compact folders that only contain a single folder into one node in the file tree)

This feature does not exist.

Originally posted by @cseickel in #211 (comment)

@cseickel cseickel added the enhancement New feature or request label Mar 27, 2022
@nyngwang
Copy link

Lol, this sounds so Java.

@caenrique
Copy link

this would be very nice

@cseickel
Copy link
Contributor Author

I just pushed this to main. It's on by default for the "buffers" source only. To enable it for the "filesystem" source, add this option:

    require("neo-tree").setup({
      filesystem = {
        group_empty_dirs = true,
      }
    })

@axieax
Copy link

axieax commented Apr 28, 2022

Thanks for implementing this feature! Not sure why but can we render collapsible directories earlier as well. Please see the demo where directory lua and only subdirectory axie are rendered as nested directories initially, but become lua/axie (expected behaviour) after toggling the neo-tree.

group_empty.mp4

@cseickel
Copy link
Contributor Author

cseickel commented Apr 28, 2022

The problem there is that those folders are being lazy loaded, and the grouping only runs on the set of folders being loaded in a particular scan, which is just the one level for a lazy load.

I think what I should do is that when a folder is opened that contains nothing but a single sub folder, I should keep loading children until I get to the end of what should be collapsed so I can group the set of dirs in one go.

@cseickel
Copy link
Contributor Author

Ok, this is fixed. I did not end up trying to look ahead and pre-group folders, I feel like that would be a dangerous can of worms I don't want to get into.

It was surprisingly difficult to get this right. What it does now is that as you drill down into a folder that should be grouped, it just adds that extra level onto the current folder.

@axieax
Copy link

axieax commented Apr 30, 2022

Thanks for the fix! I think a great part of this feature would be to reduce keystrokes when expanding directories, so having to press <CR> to expand multiple times is not ideal (nvim-tree doesn't have this issue). Totally understand if it'll be too buggy tho!

@nyngwang
Copy link

@axieax But then it will be inconvenient to create a folder/file in the middle level.

@axieax
Copy link

axieax commented Apr 30, 2022

But then it will be inconvenient to create a folder/file in the middle level.

Oh that's true, although it shouldn't be too many extra steps with #269. I feel like navigation of nested folders is a more common use case than adding a file/folder within a middle level, especially since once this file/folder is added, group_empty will no longer be needed, so adding future files/folders won't require this much expansion.

@cseickel
Copy link
Contributor Author

Thanks for the fix! I think a great part of this feature would be to reduce keystrokes when expanding directories, so having to press <CR> to expand multiple times is not ideal (nvim-tree doesn't have this issue). Totally understand if it'll be too buggy tho!

I'm mostly concerned with performance issues. Right now I only fetch one level at a time and lazy load everything else. Pre-grouping requires pre-fetching recursively and then I have to deal with those users that have performance issues because they have 10,000 folders in their project, or who knows what other issue affecting their performance.

The deciding factor for me is that I don't actually like the feature for the "filesystem" source myself, so I don't want to do anything risky with it. Someone else could try to take it on and I'd entertain a PR. I mainly did it because I wanted the feature for the "buffers" source which doesn't need any lazy loading at all.

@cseickel
Copy link
Contributor Author

cseickel commented Apr 30, 2022

But then it will be inconvenient to create a folder/file in the middle level.

That could be confusing at first, but you can always input the new file/folder name with ../file.txt and it will work even after the grouping happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants