I have created a TreeDataProvider
and populated it with TreeItem s
. I would like to be able to set the TreeItem
that is selected based on the current editor window, like happens in the Explorer/Open Editors view.
I have looked through the API but cannot find any way to do this.
@:jsRequire("vscode","Uri") A universal resource identifier representing either a file on disk or another resource, like untitled resources.
VS Code provides two powerful commands to navigate in and across files with easy-to-use key bindings. Hold Ctrl and press Tab to view a list of all files open in an editor group. To open one of these files, use Tab again to pick the file you want to navigate to, then release Ctrl to open it.
You can use the reveal()
API that was added in VSCode 1.21.0 (February 2018) for this.
This requires you to first obtain a TreeView
instance using createTreeView()
:
const treeView = vscode.window.createTreeView("viewId", {treeDataProvider: provider});
treeView.reveal(item, {select: true});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With