Vscode: Explorer: allow to expand a sub-tree fully via Alt-click

Created on 18 Jul 2016  ·  38Comments  ·  Source: microsoft/vscode

It would be nice to have a feature where you could alt+click on a folder and all of its subfolders (recursive) would either expand/collapse based on the clicked folder.

  • [ ] If I alt+click on a collapsed folder, the current folder and it's sub-folders will expand (recursive)
  • [x] If I alt+click on a expanded folder, the current folder and it's sub-folders will collapse (recursive) (this is covered and supported via https://github.com/Microsoft/vscode/issues/32550)
feature-request file-explorer on-testplan

Most helpful comment

By they way guys, there is a collapse all folders button which is a good way to clean up, atleast as a place holder until we get support for this.

image

(The 4th icon on the right there)

All 38 comments

Interesting idea, I wonder how common this is in other tools. How much do you need to learn to find this (hidden) feature if it is not standard?

Unity 3d has this feature and it is very useful when you start to have many sub levels expanded and you need to close close them. I use the feature all the time in unity and always wish it was available in code as well.

I seem to be 28 days late to the party, but this is also a feature in Atom that I'm sorely missing. With auto-reveal turned on and a large complex project, it can take forever to clean up the explorer, manually closing each directory all the way up to the root.

This has been a thing on a Mac for a very long time in Finder so I'd say it's standard. I'd love to see this implemented.

quick insert: who knows how to expand/collapse the tree in the explorer view by some shortcut key?

The tree soon expands crazily after you navigate to several code definitions/references...

By they way guys, there is a collapse all folders button which is a good way to clean up, atleast as a place holder until we get support for this.

image

(The 4th icon on the right there)

It would be nice if that option could be bound to a keypress. Also, an "expand all" option could also be useful.

@crswll It actually works in all Cocoa tree views like iTunes, iPhone, and Xcode.

In all Jetbrains IDEA based editors, the default behaviour when collapsing a folder is to collapse all of it's children.

I wonder how common this is in other tools

Photoshop's layer folders behave this way (alt+click expands/collapses all child folders)

I've implemented the 'alt + click' feature and have a pull request here https://github.com/Microsoft/vscode/pull/20826

The issue blocking this is that when you have thousands of directories open and reload the editor there is a significant delay before the explorer is displayed. I haven't had a chance to look into that yet but if anyone wants to help out with that we could probably get this feature in.

Awesome, looking forward to this, just want to note that Sublime also behaves this way so it seems pretty standard!

this features has avaliable in vscode? i still cannot find any collapse

@NAllred91, thanks for the update!
but if the blocking issue is because of the expanding feature, can't you just separate your PR into two different features- collapse all sub dirs and expand all sub dirs.
this way we could at least enjoy the collapse all feature until the performance issue of the expand all will be solved.
BTW in my opinion collapse all is way more common then expand all.

How would that behave? Just have alt-click collapse all if the directory is open and expand a single level if not?

Or should alt-click do nothing if the directory is open?

On Jun 21, 2017, at 8:49 AM, Nir Yosef notifications@github.com wrote:

@NAllred91, thanks for the update!
but if the blocking issue is because of the expanding feature, can't you just separate your PR into two different features- collapse all sub dirs and expand all sub dirs.
this way we could at least enjoy the collapse all feature until the performance issue of the expand all will be solved.
BTW in my opinion collapse all is way more common then expand all.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@NAllred91 alt-click on an open folder will collapse all, and alt-click on a closed folder will just open the folder (ignoring the alt key, it will just act as a regular click).
I think this is the more common use case, your are working on a directory with many sub dirs and after a while it gets messy and you want to collapse all the sub dirs, then you will just alt-click the folder, it will be closed and all the sub dirs will be closed too.

you already implemented it, just tweak your pull request and take out the problematic "expand all" feature and we will be left with the more useful and perfectly implemented "collapse all" feature.

Yea, I'll take a look tonight. Should be simple.

On Jun 23, 2017, at 8:32 AM, Nir Yosef notifications@github.com wrote:

@NAllred91 alt-click on an open folder will collapse all, and alt-click on a closed folder will just open the folder (ignoring the alt key, it will just act as a regular click).
I think this is the more common use case, your are working on a directory with many sub dirs and after a while it gets messy and you want to collapse all the sub dirs, then you will just alt-click the folder, it will be closed and all the sub dirs will be closed too.

you already implemented it, just tweak your pull request and take out the problematic "expand all" feature and we will be left with the more useful and perfectly implemented "collapse all" feature.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Sorry it took a week, but I've removed the "expand all" functionality from my pull request. My pull request now will just collapse all. I agree that this is a lot more useful than expanding all.

Hopefully theyll be ok with only having partial functionality. Atom has the same performance issues I was seeing, so this may not be something that has a full acceptable solution.

In sublime there is the "expand all" too but, yes, "collapse all" is better than nothing.

I'm confused what you guys are implementing here, there's already a collapse all button in VS code.

image

@deehuey Yes, there is a collapse all button. But that collapses all directories. This functionality targets collapsing a specified directory. The normal use case would be, if I am working in a directory 4 levels down from the root and expanding many directories within that directory, it is convenient to do a "collapse all" on the specific directory I am working from instead of collapsing every directory and then navigating back down 4 levels to the directory I'm working in. As far as I know, alt-click to expand/collapse all is a pretty standard feature.

Yeah, I used this religiously with Atom and it's breaking my :heart: with VSCode. Would love to see Alt-Click collapse/expand a tree.

I need this feature too it's different between collapse all button(already have) and collapse some folder (still no have) with some key shortcut eg: alt+click

Another 👍 for this feature - sorely needed, esp coming from Atom as @rawkode said.

We need alt+click to expand/collapse parent (clicked) tree and shift+click to do the same including child nodes. Listen to :octocat: Bill Gates!

Another :+1: for this feature

On a mac the keyboard shortcuts are pretty handy for this. Unlike Sublime Text 3, Visual Studio Code lets you navigate the file explorer with the keyboard. It seems the ← and → arrow keys will open and close the selected folder. However, unlike most other mac applications, the ⌥← and ⌥→ keys do not similarly collapse or expand subfolders. When you're somewhere in a subfolder repeatedly pressing ⌥← will close and jump you to the next level up in the folder structure. Perhaps this could be added along with the other support being requested here?

Note that you can get to the explorer with ⌘⇧E if it's not open or ⌘0 if it is already open to explorer.

@dalemanthei I agree, the first step is getting https://github.com/Microsoft/vscode/pull/20826 merged. But unfortunately https://github.com/Microsoft/vscode/pull/20826 now only supports recursive collapsing because of performance issues. I tried for awhile but I haven't come up with any way to recursively expand in a way that doesn't cause these performance issues. Once that is worked out it probably isn't too difficult to add these additional hot keys.

@NAllred91 I browsed the comments in the PR. Recursively opening node_modules didn't occur to me. I wonder if the recursive open could take into account the search.exclude setting and only go one level at a time for those?

In my settings it looks like:

  "search.exclude": {
    "**/build": true,
    "**/node_modules": true,
    "**/bower_components": true,
    "**/jspm_packages": true,
    "**/typings": true,
    "**/dist": true,
    "**/dll": true
  },

I suppose it depends on how you like to search those folders. If I'm looking for something in node_modules I will use the Silver Searcher in a terminal session.

@dalemanthei I think they are just using node_modules as an example for a large directory. I may be wrong, but it doesn't seem like any solution that can't handle recursively expanding a large directory without a performance hit would be acceptable.

I don't even know that this is possible in an electron app, compare atom vs sublime. Perhaps you could delay the expansion of deeper directories so they expand more slowly and don't use up all the ticks on the event loop?

With https://github.com/Microsoft/vscode/pull/32475 landing, you can Alt+click on a node in the explorer to collapse the entire tree. Due to outstanding performance issues with this operation in the expand case, expanding all nodes via Alt+click is not yet provided.

Maybe something like FoldFolderLevel1, FoldFolderLevel2, etc.

Can you bind the collapse all folders to a keyboard shortcut?

For an expand feature, could you limit it so that if there are more than x folders in folder y, stop expansion on that folder?

  AA
    F1
    F2
  BB
    F1
      F1-1
      F1-2
    F2
      F2-1
      F2-2
    ...
    F100
      F100-1
      F100-2
    F101
      F101-1
      F101-2
  CC
    F1
    F2

So, with the above folder structure, all folders will expand all the way except for BB, that will only expand itself but it's children will not expand due to the fact that it has more than then x children (in this case 100).

@jonathan-zageno You can add a keyboard shortcut yourself to the keybindings.json file:

{ "key": "cmd+[",                 "command": "workbench.files.action.collapseExplorerFolders",
                                  "when": "explorerViewletFocus && explorerViewletVisible" }

this will just collapse the folders but will not expand all folders

@isidorn What's the resolution for this feature request? Closing without any further reference is a bit confusing :)

This should work now. Is implemented as part of https://github.com/Microsoft/vscode/pull/65008
Please note this limitation https://github.com/Microsoft/vscode/issues/66811

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukehoban picture lukehoban  ·  3Comments

trstringer picture trstringer  ·  3Comments

mrkiley picture mrkiley  ·  3Comments

v-pavanp picture v-pavanp  ·  3Comments

shanalikhan picture shanalikhan  ·  3Comments