Skip to content

Selection and expansion state is lost after tree node label change #40018

@weinand

Description

@weinand

The custom explorer's selection and expansion state is only retained, if the label of the tree node does not change.
If the label changes (e.g. because one part of it reflects a dynamically changing status), the selection and expansion state is lost.

Please note that in my TreeDataProvider implementation I'm returning the same TreeItem instance for the same tree node, so I'm not deleting a TreeItem and I'm not creating a new in its place. In this case the VS Code custom tree should have no problem to preserve the selection because the TreeNode instance does not change (only its label). It should not use the label as a unique ID but assign a unique ID to the TreeItems on its own.

And even when using a TreeDataProvider implementation that returns new TreeItems on every refresh it should be possible that the selection is preserved. For this the TreeItem could support an id attribute that could be overwritten if necessary.

Since the lost selection makes a dynamic tree very difficult to use for users, I think this is an "important" bug.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugtree-viewsExtension tree view issuesverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions