@@ -18,6 +18,9 @@ import {
1818 WorkspaceQuery ,
1919} from "./workspace/workspacesProvider" ;
2020
21+ const MY_WORKSPACES_TREE_ID = "myWorkspaces" ;
22+ const ALL_WORKSPACES_TREE_ID = "allWorkspaces" ;
23+
2124export async function activate ( ctx : vscode . ExtensionContext ) : Promise < void > {
2225 // The Remote SSH extension's proposed APIs are used to override the SSH host
2326 // name in VS Code itself. It's visually unappealing having a lengthy name!
@@ -86,15 +89,15 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
8689
8790 // createTreeView, unlike registerTreeDataProvider, gives us the tree view API
8891 // (so we can see when it is visible) but otherwise they have the same effect.
89- const myWsTree = vscode . window . createTreeView ( "myWorkspaces" , {
92+ const myWsTree = vscode . window . createTreeView ( MY_WORKSPACES_TREE_ID , {
9093 treeDataProvider : myWorkspacesProvider ,
9194 } ) ;
9295 myWorkspacesProvider . setVisibility ( myWsTree . visible ) ;
9396 myWsTree . onDidChangeVisibility ( ( event ) => {
9497 myWorkspacesProvider . setVisibility ( event . visible ) ;
9598 } ) ;
9699
97- const allWsTree = vscode . window . createTreeView ( "allWorkspaces" , {
100+ const allWsTree = vscode . window . createTreeView ( ALL_WORKSPACES_TREE_ID , {
98101 treeDataProvider : allWorkspacesProvider ,
99102 } ) ;
100103 allWorkspacesProvider . setVisibility ( allWsTree . visible ) ;
@@ -298,6 +301,12 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
298301 "coder.viewLogs" ,
299302 commands . viewLogs . bind ( commands ) ,
300303 ) ;
304+ vscode . commands . registerCommand ( "coder.searchMyWorkspaces" , async ( ) =>
305+ showTreeViewSearch ( MY_WORKSPACES_TREE_ID ) ,
306+ ) ;
307+ vscode . commands . registerCommand ( "coder.searchAllWorkspaces" , async ( ) =>
308+ showTreeViewSearch ( ALL_WORKSPACES_TREE_ID ) ,
309+ ) ;
301310
302311 // Since the "onResolveRemoteAuthority:ssh-remote" activation event exists
303312 // in package.json we're able to perform actions before the authority is
@@ -421,3 +430,8 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
421430 }
422431 }
423432}
433+
434+ async function showTreeViewSearch ( id : string ) : Promise < void > {
435+ await vscode . commands . executeCommand ( `${ id } .focus` ) ;
436+ await vscode . commands . executeCommand ( "list.find" ) ;
437+ }
0 commit comments