is there any way to collapse the tree view programatically.
I want to collapse my tree view when a button is clicked
PFA Screenshot.
I want Minimise the Firmware Layout View when 'Locate in Project View' is clicked.
is there any way to collapse the tree view programatically.
I want to collapse my tree view when a button is clicked
PFA Screenshot.
I want Minimise the Firmware Layout View when 'Locate in Project View' is clicked.
There is a commit with a new command which may help, see 157410 Add Command to Fully Collapse Tree Items and in that commit this command:
list.collapseAllToFocus
[Update: now that I can test this I don't think this new command does what you need - it doesn't get to the top of the view and collapse that. It does collapse any included item and any of its included subItem items (so collapsing recursively - which is new) - but not at the top level, which is what you need.]
Here is an issue on this: API to programatically expand/collapse tree view
You can collapse that view - its contents only - but it appears you can't actually close the view itself - so it is reduced to a single line. Which I think is what you want. To collapse the contents so they are not visible (but still taking up their previous vertical space) read on. If there were a way to focus that view header
which I believe it is called, then it would be easy to collapse the entire thing with the list.collapse
command.
If you have your extension running, either in the Extension Host for testing or an installed version, look in the Keyboard Shortcuts
and type collapse
. You will see that vscode automatically creates a command like this:
workbench.actions.treeView.*******.collapseAll
with your treeView id
where the asterisks are.
So you could call that command the usual way with:
vscode.commands.executeCommand('workbench.actions.treeView.IDHere.collapseAll');
By the way, vscode also creates a
workbench.actions.treeView.someTreeViewIDHere.refresh
command for all custom TreeViews.