I am currently developing a custom VS Code extension that incorporates a unique viewsContainer. The activation of this container is triggered by an onView:
event defined in the package JSON.
The functionality works seamlessly, with my view fetching data from a static JSON file and efficiently adding each node to the view.
The structure of my JSON data is as follows:
{
"name": "root",
"children": {
"Child1": [
{ "id": "childId1", "name": "childName1" },
{ "id": "childId2", "name": "childId2" }
],
"Child2": [
{ "id": "childId1", "name": "childName1" },
{ "id": "childId2", "name": "childId2" }
],
...
}
}
The class registered as a treeviewprovider in extension.ts
looks like this:
...
In summary, I have encountered an issue where expanding an item in the view results in the entire JSON schema being repeated underneath it. It seems that the getChildren()
method is called both during registration and at every expand event.
My query pertains to identifying the flaw in my implementation within getValidateMenu()
to prevent duplicating the schema on collapsed items and correctly grouping their child objects under the respective parent item.
Could setting commands for the immediate root.children
items, linking to an onclick
method for revealing their children, be a potential solution?
I would greatly appreciate any guidance or advice from individuals more knowledgeable in this area. Thank you.