Support object types for TreeItem.contextValue
#74699
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
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
acontextValue
string with a space-separated list of tags, and using regular expressions in mywhen
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 usingviewItem.propName
, similar to the existing support forcontext.propName
that already exists.Proposed changes:
TreeItem.contextValue
toany
(or some suitably restricted type that allows an object type)when
condition,viewItem.propName
accesses the property namedpropName
onTreeItem.contextValue
, ifTreeItem.contextValue
is an object type.If this sounds like a reasonable feature, I'm willing to contribute the PR to implement it.
The text was updated successfully, but these errors were encountered: