@@ -54,6 +54,8 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
5454 }
5555
5656 const serviceContainer = new ServiceContainer ( ctx , vscodeProposed ) ;
57+ ctx . subscriptions . push ( serviceContainer ) ;
58+
5759 const output = serviceContainer . getLogger ( ) ;
5860 const mementoManager = serviceContainer . getMementoManager ( ) ;
5961 const secretsManager = serviceContainer . getSecretsManager ( ) ;
@@ -69,7 +71,6 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
6971 url || "" ,
7072 await secretsManager . getSessionToken ( ) ,
7173 output ,
72- ( ) => vscode . workspace . getConfiguration ( ) ,
7374 ) ;
7475
7576 const myWorkspacesProvider = new WorkspaceProvider (
@@ -78,33 +79,47 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
7879 output ,
7980 5 ,
8081 ) ;
82+ ctx . subscriptions . push ( myWorkspacesProvider ) ;
83+
8184 const allWorkspacesProvider = new WorkspaceProvider (
8285 WorkspaceQuery . All ,
8386 client ,
8487 output ,
8588 ) ;
89+ ctx . subscriptions . push ( allWorkspacesProvider ) ;
8690
8791 // createTreeView, unlike registerTreeDataProvider, gives us the tree view API
8892 // (so we can see when it is visible) but otherwise they have the same effect.
8993 const myWsTree = vscode . window . createTreeView ( "myWorkspaces" , {
9094 treeDataProvider : myWorkspacesProvider ,
9195 } ) ;
96+ ctx . subscriptions . push ( myWsTree ) ;
9297 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+ ) ;
96105
97106 const allWsTree = vscode . window . createTreeView ( "allWorkspaces" , {
98107 treeDataProvider : allWorkspacesProvider ,
99108 } ) ;
109+ ctx . subscriptions . push ( allWsTree ) ;
100110 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+ ) ;
104118
105119 // Handle vscode:// URIs.
106- vscode . window . registerUriHandler ( {
120+ const uriHandler = vscode . window . registerUriHandler ( {
107121 handleUri : async ( uri ) => {
122+ const cliManager = serviceContainer . getCliManager ( ) ;
108123 const params = new URLSearchParams ( uri . query ) ;
109124 if ( uri . path === "/open" ) {
110125 const owner = params . get ( "owner" ) ;
@@ -250,53 +265,79 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
250265 }
251266 } ,
252267 } ) ;
253-
254- const cliManager = serviceContainer . getCliManager ( ) ;
268+ ctx . subscriptions . push ( uriHandler ) ;
255269
256270 // Register globally available commands. Many of these have visibility
257271 // controlled by contexts, see `when` in the package.json.
258272 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+ ) ,
263278 ) ;
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+ ) ,
268284 ) ;
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 ) ) ,
272287 ) ;
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+ ) ,
276293 ) ;
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+ ) ,
280299 ) ;
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+ ) ,
284305 ) ;
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+ ) ,
288311 ) ;
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+ ) ,
292317 ) ;
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+ ) ,
300341 ) ;
301342
302343 // Since the "onResolveRemoteAuthority:ssh-remote" activation event exists
@@ -316,6 +357,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
316357 isFirstConnect ,
317358 ) ;
318359 if ( details ) {
360+ ctx . subscriptions . push ( details ) ;
319361 // Authenticate the plugin client which is used in the sidebar to display
320362 // workspaces belonging to this deployment.
321363 client . setHost ( details . url ) ;
0 commit comments