diff options
Diffstat (limited to 'src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts')
-rw-r--r-- | src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts b/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts index f57e3cb5db6..1040b35beff 100644 --- a/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts +++ b/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts @@ -182,6 +182,11 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench } async setEnablement(extensions: IExtension[], newState: EnablementState): Promise<boolean[]> { + await this.extensionsManager.whenInitialized(); + + if (newState === EnablementState.EnabledGlobally || newState === EnablementState.EnabledWorkspace) { + extensions.push(...this.getExtensionsToEnableRecursively(extensions, this.extensionsManager.extensions, newState, { dependencies: true, pack: true })); + } const workspace = newState === EnablementState.DisabledWorkspace || newState === EnablementState.EnabledWorkspace; for (const extension of extensions) { @@ -213,6 +218,33 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench return result; } + private getExtensionsToEnableRecursively(extensions: IExtension[], allExtensions: ReadonlyArray<IExtension>, enablementState: EnablementState, options: { dependencies: boolean; pack: boolean }, checked: IExtension[] = []): IExtension[] { + const toCheck = extensions.filter(e => checked.indexOf(e) === -1); + if (toCheck.length) { + for (const extension of toCheck) { + checked.push(extension); + } + const extensionsToDisable = allExtensions.filter(i => { + if (checked.indexOf(i) !== -1) { + return false; + } + if (this.getEnablementState(i) === enablementState) { + return false; + } + return (options.dependencies || options.pack) + && extensions.some(extension => + (options.dependencies && extension.manifest.extensionDependencies?.some(id => areSameExtensions({ id }, i.identifier))) + || (options.pack && extension.manifest.extensionPack?.some(id => areSameExtensions({ id }, i.identifier))) + ); + }); + if (extensionsToDisable.length) { + extensionsToDisable.push(...this.getExtensionsToEnableRecursively(extensionsToDisable, allExtensions, enablementState, options, checked)); + } + return extensionsToDisable; + } + return []; + } + private _setUserEnablementState(extension: IExtension, newState: EnablementState): Promise<boolean> { const currentState = this._getUserEnablementState(extension.identifier); |