@@ -16,6 +16,9 @@ import { Remote } from "./remote";
1616import { toSafeHost } from "./util" ;
1717import { WorkspaceProvider , WorkspaceQuery } from "./workspacesProvider" ;
1818
19+ const MY_WORKSPACES_TREE_ID = "myWorkspaces" ;
20+ const ALL_WORKSPACES_TREE_ID = "myWorkspaces" ;
21+
1922export async function activate ( ctx : vscode . ExtensionContext ) : Promise < void > {
2023 // The Remote SSH extension's proposed APIs are used to override the SSH host
2124 // name in VS Code itself. It's visually unappealing having a lengthy name!
@@ -88,15 +91,15 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
8891
8992 // createTreeView, unlike registerTreeDataProvider, gives us the tree view API
9093 // (so we can see when it is visible) but otherwise they have the same effect.
91- const myWsTree = vscode . window . createTreeView ( "myWorkspaces" , {
94+ const myWsTree = vscode . window . createTreeView ( MY_WORKSPACES_TREE_ID , {
9295 treeDataProvider : myWorkspacesProvider ,
9396 } ) ;
9497 myWorkspacesProvider . setVisibility ( myWsTree . visible ) ;
9598 myWsTree . onDidChangeVisibility ( ( event ) => {
9699 myWorkspacesProvider . setVisibility ( event . visible ) ;
97100 } ) ;
98101
99- const allWsTree = vscode . window . createTreeView ( "allWorkspaces" , {
102+ const allWsTree = vscode . window . createTreeView ( ALL_WORKSPACES_TREE_ID , {
100103 treeDataProvider : allWorkspacesProvider ,
101104 } ) ;
102105 allWorkspacesProvider . setVisibility ( allWsTree . visible ) ;
@@ -308,6 +311,12 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
308311 "coder.viewLogs" ,
309312 commands . viewLogs . bind ( commands ) ,
310313 ) ;
314+ vscode . commands . registerCommand ( "coder.searchMyWorkspaces" , async ( ) =>
315+ showTreeViewSearch ( MY_WORKSPACES_TREE_ID ) ,
316+ ) ;
317+ vscode . commands . registerCommand ( "coder.searchAllWorkspaces" , async ( ) =>
318+ showTreeViewSearch ( ALL_WORKSPACES_TREE_ID ) ,
319+ ) ;
311320
312321 // Since the "onResolveRemoteAuthority:ssh-remote" activation event exists
313322 // in package.json we're able to perform actions before the authority is
@@ -436,3 +445,8 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
436445 }
437446 }
438447}
448+
449+ async function showTreeViewSearch ( id : string ) : Promise < void > {
450+ await vscode . commands . executeCommand ( `${ id } .focus` ) ;
451+ await vscode . commands . executeCommand ( "list.find" ) ;
452+ }
0 commit comments