@@ -57,6 +57,8 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
57
57
}
58
58
59
59
const serviceContainer = new ServiceContainer ( ctx , vscodeProposed ) ;
60
+ ctx . subscriptions . push ( serviceContainer ) ;
61
+
60
62
const output = serviceContainer . getLogger ( ) ;
61
63
const mementoManager = serviceContainer . getMementoManager ( ) ;
62
64
const secretsManager = serviceContainer . getSecretsManager ( ) ;
@@ -72,7 +74,6 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
72
74
url || "" ,
73
75
await secretsManager . getSessionToken ( ) ,
74
76
output ,
75
- ( ) => vscode . workspace . getConfiguration ( ) ,
76
77
) ;
77
78
78
79
const myWorkspacesProvider = new WorkspaceProvider (
@@ -81,33 +82,47 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
81
82
output ,
82
83
5 ,
83
84
) ;
85
+ ctx . subscriptions . push ( myWorkspacesProvider ) ;
86
+
84
87
const allWorkspacesProvider = new WorkspaceProvider (
85
88
WorkspaceQuery . All ,
86
89
client ,
87
90
output ,
88
91
) ;
92
+ ctx . subscriptions . push ( allWorkspacesProvider ) ;
89
93
90
94
// createTreeView, unlike registerTreeDataProvider, gives us the tree view API
91
95
// (so we can see when it is visible) but otherwise they have the same effect.
92
96
const myWsTree = vscode . window . createTreeView ( MY_WORKSPACES_TREE_ID , {
93
97
treeDataProvider :myWorkspacesProvider ,
94
98
} ) ;
99
+ ctx . subscriptions . push ( myWsTree ) ;
95
100
myWorkspacesProvider . setVisibility ( myWsTree . visible ) ;
96
- myWsTree . onDidChangeVisibility ( ( event ) => {
97
- myWorkspacesProvider . setVisibility ( event . visible ) ;
98
- } ) ;
101
+ myWsTree . onDidChangeVisibility (
102
+ ( event ) => {
103
+ myWorkspacesProvider . setVisibility ( event . visible ) ;
104
+ } ,
105
+ undefined ,
106
+ ctx . subscriptions ,
107
+ ) ;
99
108
100
109
const allWsTree = vscode . window . createTreeView ( ALL_WORKSPACES_TREE_ID , {
101
110
treeDataProvider :allWorkspacesProvider ,
102
111
} ) ;
112
+ ctx . subscriptions . push ( allWsTree ) ;
103
113
allWorkspacesProvider . setVisibility ( allWsTree . visible ) ;
104
- allWsTree . onDidChangeVisibility ( ( event ) => {
105
- allWorkspacesProvider . setVisibility ( event . visible ) ;
106
- } ) ;
114
+ allWsTree . onDidChangeVisibility (
115
+ ( event ) => {
116
+ allWorkspacesProvider . setVisibility ( event . visible ) ;
117
+ } ,
118
+ undefined ,
119
+ ctx . subscriptions ,
120
+ ) ;
107
121
108
122
// Handle vscode:// URIs.
109
- vscode . window . registerUriHandler ( {
123
+ const uriHandler = vscode . window . registerUriHandler ( {
110
124
handleUri :async ( uri ) => {
125
+ const cliManager = serviceContainer . getCliManager ( ) ;
111
126
const params = new URLSearchParams ( uri . query ) ;
112
127
if ( uri . path === "/open" ) {
113
128
const owner = params . get ( "owner" ) ;
@@ -253,59 +268,63 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
253
268
}
254
269
} ,
255
270
} ) ;
256
-
257
- const cliManager = serviceContainer . getCliManager ( ) ;
271
+ ctx . subscriptions . push ( uriHandler ) ;
258
272
259
273
// Register globally available commands. Many of these have visibility
260
274
// controlled by contexts, see `when` in the package.json.
261
275
const commands = new Commands ( serviceContainer , client ) ;
262
- vscode . commands . registerCommand ( "coder.login" , commands . login . bind ( commands ) ) ;
263
- vscode . commands . registerCommand (
264
- "coder.logout" ,
265
- commands . logout . bind ( commands ) ,
266
- ) ;
267
- vscode . commands . registerCommand ( "coder.open" , commands . open . bind ( commands ) ) ;
268
- vscode . commands . registerCommand (
269
- "coder.openDevContainer" ,
270
- commands . openDevContainer . bind ( commands ) ,
271
- ) ;
272
- vscode . commands . registerCommand (
273
- "coder.openFromSidebar" ,
274
- commands . openFromSidebar . bind ( commands ) ,
275
- ) ;
276
- vscode . commands . registerCommand (
277
- "coder.openAppStatus" ,
278
- commands . openAppStatus . bind ( commands ) ,
279
- ) ;
280
- vscode . commands . registerCommand (
281
- "coder.workspace.update" ,
282
- commands . updateWorkspace . bind ( commands ) ,
283
- ) ;
284
- vscode . commands . registerCommand (
285
- "coder.createWorkspace" ,
286
- commands . createWorkspace . bind ( commands ) ,
287
- ) ;
288
- vscode . commands . registerCommand (
289
- "coder.navigateToWorkspace" ,
290
- commands . navigateToWorkspace . bind ( commands ) ,
291
- ) ;
292
- vscode . commands . registerCommand (
293
- "coder.navigateToWorkspaceSettings" ,
294
- commands . navigateToWorkspaceSettings . bind ( commands ) ,
295
- ) ;
296
- vscode . commands . registerCommand ( "coder.refreshWorkspaces" , ( ) => {
297
- myWorkspacesProvider . fetchAndRefresh ( ) ;
298
- allWorkspacesProvider . fetchAndRefresh ( ) ;
299
- } ) ;
300
- vscode . commands . registerCommand (
301
- "coder.viewLogs" ,
302
- commands . viewLogs . bind ( commands ) ,
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 ) ,
276
+ ctx . subscriptions . push (
277
+ vscode . commands . registerCommand (
278
+ "coder.login" ,
279
+ commands . login . bind ( commands ) ,
280
+ ) ,
281
+ vscode . commands . registerCommand (
282
+ "coder.logout" ,
283
+ commands . logout . bind ( commands ) ,
284
+ ) ,
285
+ vscode . commands . registerCommand ( "coder.open" , commands . open . bind ( commands ) ) ,
286
+ vscode . commands . registerCommand (
287
+ "coder.openDevContainer" ,
288
+ commands . openDevContainer . bind ( commands ) ,
289
+ ) ,
290
+ vscode . commands . registerCommand (
291
+ "coder.openFromSidebar" ,
292
+ commands . openFromSidebar . bind ( commands ) ,
293
+ ) ,
294
+ vscode . commands . registerCommand (
295
+ "coder.openAppStatus" ,
296
+ commands . openAppStatus . bind ( commands ) ,
297
+ ) ,
298
+ vscode . commands . registerCommand (
299
+ "coder.workspace.update" ,
300
+ commands . updateWorkspace . bind ( commands ) ,
301
+ ) ,
302
+ vscode . commands . registerCommand (
303
+ "coder.createWorkspace" ,
304
+ commands . createWorkspace . bind ( commands ) ,
305
+ ) ,
306
+ vscode . commands . registerCommand (
307
+ "coder.navigateToWorkspace" ,
308
+ commands . navigateToWorkspace . bind ( commands ) ,
309
+ ) ,
310
+ vscode . commands . registerCommand (
311
+ "coder.navigateToWorkspaceSettings" ,
312
+ commands . navigateToWorkspaceSettings . bind ( commands ) ,
313
+ ) ,
314
+ vscode . commands . registerCommand ( "coder.refreshWorkspaces" , ( ) => {
315
+ myWorkspacesProvider . fetchAndRefresh ( ) ;
316
+ allWorkspacesProvider . fetchAndRefresh ( ) ;
317
+ } ) ,
318
+ vscode . commands . registerCommand (
319
+ "coder.viewLogs" ,
320
+ commands . viewLogs . bind ( commands ) ,
321
+ ) ,
322
+ vscode . commands . registerCommand ( "coder.searchMyWorkspaces" , async ( ) =>
323
+ showTreeViewSearch ( MY_WORKSPACES_TREE_ID ) ,
324
+ ) ,
325
+ vscode . commands . registerCommand ( "coder.searchAllWorkspaces" , async ( ) =>
326
+ showTreeViewSearch ( ALL_WORKSPACES_TREE_ID ) ,
327
+ ) ,
309
328
) ;
310
329
311
330
// Since the "onResolveRemoteAuthority:ssh-remote" activation event exists
@@ -325,6 +344,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
325
344
isFirstConnect ,
326
345
) ;
327
346
if ( details ) {
347
+ ctx . subscriptions . push ( details ) ;
328
348
// Authenticate the plugin client which is used in the sidebar to display
329
349
// workspaces belonging to this deployment.
330
350
client . setHost ( details . url ) ;