Skip to content
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

Add Expand all button in explorer view #153614

Merged
merged 1 commit into from
Jul 11, 2022

Conversation

jzyrobert
Copy link
Contributor

This PR fixes #88682

Demo:

vcxsrv_ZwlqrpifFZ.mp4

Added changes:

  • New RawContextKey ViewHasSomeCollapsibleRootItemContext that tracks tree status for swapping buttons
  • hasExpandedRootChild updated to work with a non-workspace tree as well
  • updateAnyCollapsedContext updates ViewHasSomeCollapsibleRootItemContext using onDidChangeCollapseState
  • new Action2 that is mostly a copy of "Collapse All"

This button behaves like the exact opposite of the "Collapse All" button, and only shows when all root folders in all open workspace folders are collapsed (does not check closed workspace folders)

  • However just like "Collapse All", running "Expand All" will affect root folders within closed workspace folders (should this behaviour be changed)

Other considerations:

  • Performance impact of onDidChangeCollapseState, this seems to run for every visible item once, so for a large workspace triggers lots of calls when using "Expand All" or "Collapse All". Could go by the comment of @JacksonKearl to make "Expand All" be the Alt-click action of "Collapse All" so the button does not have to update. (Although I don't know how to get the MouseEvent from inside the Action2 run function)
  • Make both expand/collapse button not run on closed Workspace folders

@lramos15
Copy link
Member

Thanks! We're in the process of releasing the next version of VS Code so I'll take a look at this in the coming weeks for next release. Just a an FYI if it seems that i am slow to respond.

@lramos15 lramos15 added this to the July 2022 milestone Jun 29, 2022
@jzyrobert
Copy link
Contributor Author

Thanks! We're in the process of releasing the next version of VS Code so I'll take a look at this in the coming weeks for next release. Just a an FYI if it seems that i am slow to respond.

No worries, I am aware of the monthly release cycle

Copy link
Member

@lramos15 lramos15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great and mirrors the search view well. Thanks!

@lramos15 lramos15 merged commit e7e987e into microsoft:main Jul 11, 2022
@jzyrobert jzyrobert deleted the jzyrobert/explorer_expand_all branch July 11, 2022 23:39
@gjsjohnmurray
Copy link
Contributor

Trying this in today's Insiders, it seems that for a multi-root workspace (for my testing, 2 roots) if I have both roots expanded to some depth, then click collapse, I see first-level folders in all roots and no longer get the option to click collapse a second time to collapse the roots entirely. Instead I am offered an expand option. This is a change of behaviour relative to Stable.

@lramos15
Copy link
Member

I see first-level folders in all roots and no longer get the option to click collapse a second time to collapse the roots entirely. Instead I am offered an expand option.

I think this is sort of expected. Since we wanted people to be able to expand without having their roots fully collapsed. @jzyrobert what are your thoughts here, is there any way we could restore the old behavior while still supporting expand all?

@StickNitro
Copy link

This is quite different behavior in a multi-root workspace, I have one workspace with 5 root folders and another with 10+, prior to this change clicking the collapse button in explorer would collapse all the folders in each root folder, clicking again would then collapse all the root folders. What I get now is the following:

  • If all root folders are collapsed, clicking the expand/collapse button does nothing
  • If one root folder is open the expand/collapse button expands and collapses folders within that root folder
  • More than one root folder open the same as before for all of the open root folders

Perhaps we could have an option to opt-in to this new behavior which seems like it would be perfect in a single root project

@jzyrobert
Copy link
Contributor Author

@gjsjohnmurray @lramos15 @StickNitro Sorry I've been busy. I hear your concerns, maybe we should make this a setting? Either for completely disabling it, or to make it so roots are collapsed first before the expand button is shown

@lramos15
Copy link
Member

I have updated it so it only shows expand all when all nodes are collapsed. This preserves the double collapse of multi-root. There are still some unanswered questions so I will also be disabling this feature in the stable release until we can have a better story for expand

@github-actions github-actions bot locked and limited conversation to collaborators Aug 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "Expand All" Button to Tree (make "Collapse All" toggleable)
5 participants