Filtering a Treeview

Viewed 551

I'm new to TypeScript and the VS Code API. I'm looking to learn and am creating an extension that I've wanted a long time in order to do so. I managed to create the functionality I needed (basically a filename filter) using a WebView but I'd prefer using treeview. Here's what I've got:

Unfiltered file list

unfiltered

Filtered file list

filtered

Ideally, I'd like to create this:

combo

Is this currently possible and what keywords do I need to research to make it happen?

Thanks

1 Answers

See the demo at https://stackoverflow.com/a/73039858/836330 of filtering in a TreeView. It is not part of the extension-available api though. You could trigger it in an extension with

await vscode.commands.executeCommand('workbench.files.action.focusFilesExplorer');
await vscode.commands.executeCommand('list.find');

but looking at the commit for this functionality I don't think there is any way to populate that find input from an extension - I don't think the command list.find takes any arguments. I tried a couple of ways like

await vscode.commands.executeCommand('list.find', {text: 'findMe'});
await vscode.commands.executeCommand('list.find', {query: 'findMe'});

Other find functionality in vscode can take arguments, but this filtering a treeView is brand new and will probably need a feature request if you want to populate the find input programmatically.

Related