You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow to reveal an empty TreeView programmatically #90005
Currently, it i possible to reveal/expand a TreeView only when there is an element in the TreeView. it is oputting revealing this element in the TreeView.
it would useful to be abel to expand the TreeView even when there are no elements in the Tree.
Reacted by Gary Gaughan, Tomáš Sedmík, Bruno Alejos, Dominik Jelínek, Lars Heinemann, Marian Lorinc, Melissa Flinn, Matt Crouch, Mikhail Abramov, Christina Lin and 30 more
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.
🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.
I think we should add a show method, rather than overloading reveal. This also aligns with WebviewViews which have:
show(preserveFocus?: boolean): void;
I also think we should add a hide method to both tree views and webview views (which has been requested). Which also better aligns with a show method as we use that on lots of other API objects.
Reacted by Garrett Smith, Darryl Lawson and GreenAsJade
It could, but imo that still feels more right to me. Also the reveal method has an options bag that while there is some overlap, feels strange to apply to the view itself. And I feel the alignment with WebviewViews is quite important as well.
note: the issue with the overload is that it can clash with the existing reveal definition if the properties of T are a set or subset of the options properties, which while unlikely could be confusing.
Another option is a reveal overload without any arguments.
IMHO the overload of reveal is objectively wrong :) show() is established as the function name for this (if I read the OP correctly). It's used by most (if not all) of the other view-like components (webviews, terminal, channels, etc.)
To reveal an item inside a view is view specific, whereas to make the view itself visible is something that applies to any view at all. The fact that show() doesn't exist on the tree view, and does pervasively elsewhere, looks like an implementation oversight.
The options in reveal() show that reveal(null) is nonsensical. These are node specific.
As a driver for this behavior, I want to implement a command that shows a custom tree view in the same way that any of the other views are shown. You can do this manually via View -> Open view... -> . This is the behavior that tree.show() should have IMO. This should not effect the current tree selection but merely show the view and put it into focus (same every other show view command).
Indeed, a dedicated show() would be much better especially when using a tree view with type TreeView<SomeNode> then we cannot pass undefined/null. I would have to (falsely) make it TreeView<SomeNode | undefined> and deal with the non-existent undefined or hack Typescript and do treeView.reveal(undefined as unknown as SomeNode). Both options are not ideal..
Activity
vscodebot commentedon Feb 4, 2020
(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
vscodebot commentedon Feb 5, 2020
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
vscodebot commentedon Feb 14, 2020
🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
alexr00 commentedon Nov 6, 2020
Proposal is to allow the first parameter here to be undefined:
vscode/src/vs/vscode.proposed.d.ts
Lines 1042 to 1044 in e95c40c
eamodio commentedon Nov 6, 2020
I think we should add a
showmethod, rather than overloadingreveal. This also aligns withWebviewViewswhich have:I also think we should add a
hidemethod to both tree views and webview views (which has been requested). Which also better aligns with ashowmethod as we use that on lots of other API objects.alexr00 commentedon Nov 9, 2020
I think that could result in this pattern:
eamodio commentedon Nov 9, 2020
It could, but imo that still feels more right to me. Also the
revealmethod has an options bag that while there is some overlap, feels strange to apply to the view itself. And I feel the alignment withWebviewViewsis quite important as well.wandyezj commentedon Mar 15, 2022
I'd prefer to simply allow the reveal element to be undefined (as currently proposed).
A questionable alternative is to allow an overload to
revealthat moveselementto theoptionsparameter.note: the issue with the overload is that it can clash with the existing reveal definition if the properties of
Tare a set or subset of theoptionsproperties, which while unlikely could be confusing.Another option is a reveal overload without any arguments.
I think a
show/hideAPI might be better as a separate proposal.cweijan commentedon Mar 18, 2022
I tried to pass a null to reveal, it can switch the treeview normally, which has met my needs.
gar1t commentedon Jun 17, 2022
IMHO the overload of
revealis objectively wrong :)show()is established as the function name for this (if I read the OP correctly). It's used by most (if not all) of the other view-like components (webviews, terminal, channels, etc.)To reveal an item inside a view is view specific, whereas to make the view itself visible is something that applies to any view at all. The fact that
show()doesn't exist on the tree view, and does pervasively elsewhere, looks like an implementation oversight.The options in
reveal()show thatreveal(null)is nonsensical. These are node specific.gar1t commentedon Jun 17, 2022
As a driver for this behavior, I want to implement a command that shows a custom tree view in the same way that any of the other views are shown. You can do this manually via View -> Open view... -> . This is the behavior that
tree.show()should have IMO. This should not effect the current tree selection but merely show the view and put it into focus (same every other show view command).gar1t commentedon Jun 17, 2022
Lol,
reveal(undefined)already seems to work as described above! (I'm running 1.68.1) It's not yet documented though :)I propose that an alias of
show()be added (I'm glad the behavior's at least now supported!)EhabY commentedon Jan 4, 2024
Indeed, a dedicated
show()would be much better especially when using a tree view with typeTreeView<SomeNode>then we cannot passundefined/null. I would have to (falsely) make itTreeView<SomeNode | undefined>and deal with the non-existent undefined or hack Typescript and dotreeView.reveal(undefined as unknown as SomeNode). Both options are not ideal..