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