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

Support object types for TreeItem.contextValue #74699

Closed
dave-bartolomeo opened this issue May 31, 2019 · 3 comments
Closed

Support object types for TreeItem.contextValue #74699

dave-bartolomeo opened this issue May 31, 2019 · 3 comments
Assignees
Labels
feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code tree-views Extension tree view issues
Milestone

Comments

@dave-bartolomeo
Copy link

This is a duplicate of #46236. That issue has been auto-closed, apparently due to inactivity, but I have more information about the scenario and am willing to offer a pull request.

I have an extension that contributes a treeview to the Test Explorer container. Each TreeItem represents a test, and different tests need different context menu items enabled based on properties of those tests. For example, some tests have expected output that can be compared with the actual output in a diff view, and some don't. Failed tests need an option to accept the new output as expected, but passed tests don't. The node for a test needs different options from the node for a test suite.

Today, I can sort of make this work by giving each TreeItem a contextValue string with a space-separated list of tags, and using regular expressions in my when condition to look for the interesting tags or lack thereof.

What I'd prefer is to specify an object as the value for contextValue, and be able to access individual properties of that object using viewItem.propName, similar to the existing support for context.propName that already exists.

Proposed changes:

  • Change the type of TreeItem.contextValue to any (or some suitably restricted type that allows an object type)
  • Within a when condition, viewItem.propName accesses the property named propName on TreeItem.contextValue, if TreeItem.contextValue is an object type.

If this sounds like a reasonable feature, I'm willing to contribute the PR to implement it.

@jrieken jrieken assigned sandy081 and unassigned jrieken Jun 2, 2019
@sandy081 sandy081 added tree-views Extension tree view issues feature-request Request for new features or functionality labels Jun 4, 2019
@sandy081 sandy081 added this to the Backlog milestone Jun 4, 2019
@sandy081
Copy link
Member

sandy081 commented Jun 4, 2019

This can be accepted as PR.

@dave-bartolomeo
Copy link
Author

Great. I'll try to put something together over the next few days.

@alexr00 alexr00 self-assigned this Oct 7, 2019
@alexr00 alexr00 added the *out-of-scope Posted issue is not in scope of VS Code label Nov 6, 2020
@urbanfly
Copy link

urbanfly commented May 2, 2024

@dave-bartolomeo was the PR more difficult than you had assumed? is there any reason why this feature doesn't exist yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code tree-views Extension tree view issues
Projects
None yet
Development

No branches or pull requests

6 participants
@jrieken @urbanfly @sandy081 @alexr00 @dave-bartolomeo and others