@@ -18,6 +18,9 @@ import {
18
18
WorkspaceQuery ,
19
19
} from "./workspace/workspacesProvider" ;
20
20
21
+ const MY_WORKSPACES_TREE_ID = "myWorkspaces" ;
22
+ const ALL_WORKSPACES_TREE_ID = "allWorkspaces" ;
23
+
21
24
export async function activate ( ctx : vscode . ExtensionContext ) : Promise < void > {
22
25
// The Remote SSH extension's proposed APIs are used to override the SSH host
23
26
// 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> {
86
89
87
90
// createTreeView, unlike registerTreeDataProvider, gives us the tree view API
88
91
// (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 , {
90
93
treeDataProvider : myWorkspacesProvider ,
91
94
} ) ;
92
95
myWorkspacesProvider . setVisibility ( myWsTree . visible ) ;
93
96
myWsTree . onDidChangeVisibility ( ( event ) => {
94
97
myWorkspacesProvider . setVisibility ( event . visible ) ;
95
98
} ) ;
96
99
97
- const allWsTree = vscode . window . createTreeView ( "allWorkspaces" , {
100
+ const allWsTree = vscode . window . createTreeView ( ALL_WORKSPACES_TREE_ID , {
98
101
treeDataProvider : allWorkspacesProvider ,
99
102
} ) ;
100
103
allWorkspacesProvider . setVisibility ( allWsTree . visible ) ;
@@ -298,6 +301,12 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
298
301
"coder.viewLogs" ,
299
302
commands . viewLogs . bind ( commands ) ,
300
303
) ;
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
+ ) ;
301
310
302
311
// Since the "onResolveRemoteAuthority:ssh-remote" activation event exists
303
312
// 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> {
421
430
}
422
431
}
423
432
}
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