Skip to content

Commit

Permalink
fix: only add extension if it's enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Feb 19, 2024
1 parent 4efe3d7 commit e59f286
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
import { parse } from 'vs/base/common/json'
import { IFileService } from 'vs/platform/files/common/files'
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'
import { IWorkbenchExtensionEnablementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement'
import { IExtensionWithExtHostKind, ExtensionServiceOverride } from './service-override/extensions'
import { CustomSchemas, registerExtensionFile } from './service-override/files'
import { getService } from './services'
Expand Down Expand Up @@ -41,6 +42,7 @@ interface RegisterExtensionResult {
id: string
dispose (): Promise<void>
whenReady(): Promise<void>
isEnabled(): Promise<boolean>
}

interface RegisterRemoteExtensionResult extends RegisterExtensionResult {
Expand Down Expand Up @@ -136,7 +138,11 @@ export function registerExtension (manifest: IExtensionManifest, extHostKind?: E
extensions.push(extension)
}

await deltaExtensions({ toAdd: [extension], toRemove: [] })
// Wait for extension to be enabled
const extensionEnablementService = await getService(IWorkbenchExtensionEnablementService)
if (extensionEnablementService.isEnabled(extension)) {
await deltaExtensions({ toAdd: [extension], toRemove: [] })
}

return extension
})()
Expand All @@ -146,6 +152,11 @@ export function registerExtension (manifest: IExtensionManifest, extHostKind?: E
async whenReady () {
await addExtensionPromise
},
async isEnabled () {
const extensionEnablementService = await getService(IWorkbenchExtensionEnablementService)
const extension = await addExtensionPromise
return extensionEnablementService.isEnabled(extension)
},
async dispose () {
const extension = await addExtensionPromise

Expand Down

0 comments on commit e59f286

Please sign in to comment.