@@ -16,6 +16,9 @@ import { Remote } from "./remote";
16
16
import { toSafeHost } from "./util" ;
17
17
import { WorkspaceProvider , WorkspaceQuery } from "./workspacesProvider" ;
18
18
19
+ const MY_WORKSPACES_TREE_ID = "myWorkspaces" ;
20
+ const ALL_WORKSPACES_TREE_ID = "allWorkspaces" ;
21
+
19
22
export async function activate ( ctx : vscode . ExtensionContext ) : Promise < void > {
20
23
// The Remote SSH extension's proposed APIs are used to override the SSH host
21
24
// 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> {
88
91
89
92
// createTreeView, unlike registerTreeDataProvider, gives us the tree view API
90
93
// (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 , {
92
95
treeDataProvider : myWorkspacesProvider ,
93
96
} ) ;
94
97
myWorkspacesProvider . setVisibility ( myWsTree . visible ) ;
95
98
myWsTree . onDidChangeVisibility ( ( event ) => {
96
99
myWorkspacesProvider . setVisibility ( event . visible ) ;
97
100
} ) ;
98
101
99
- const allWsTree = vscode . window . createTreeView ( "allWorkspaces" , {
102
+ const allWsTree = vscode . window . createTreeView ( ALL_WORKSPACES_TREE_ID , {
100
103
treeDataProvider : allWorkspacesProvider ,
101
104
} ) ;
102
105
allWorkspacesProvider . setVisibility ( allWsTree . visible ) ;
@@ -308,6 +311,12 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
308
311
"coder.viewLogs" ,
309
312
commands . viewLogs . bind ( commands ) ,
310
313
) ;
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
+ ) ;
311
320
312
321
// Since the "onResolveRemoteAuthority:ssh-remote" activation event exists
313
322
// 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> {
436
445
}
437
446
}
438
447
}
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