提交 2042dfa0 编写于 作者: S Sandeep Somavarapu

Fix #58775

上级 e4ede32d
...@@ -244,7 +244,7 @@ export class ExtensionsActivator { ...@@ -244,7 +244,7 @@ export class ExtensionsActivator {
if (!depDesc) { if (!depDesc) {
// Error condition 1: unknown dependency // Error condition 1: unknown dependency
this._host.showMessage(Severity.Error, nls.localize('unknownDep', "Extension '{1}' failed to activate. Reason: unknown dependency '{0}'.", depId, currentExtension.id)); this._host.showMessage(Severity.Error, nls.localize('unknownDep', "Cannot activate extension '{0}' as the depending extension '{1}' is not found. Please install or enable the depending extension and reload the window.", currentExtension.displayName || currentExtension.id, depId));
const error = new Error(`Unknown dependency '${depId}'`); const error = new Error(`Unknown dependency '${depId}'`);
this._activatedExtensions[currentExtension.id] = new FailedExtension(error); this._activatedExtensions[currentExtension.id] = new FailedExtension(error);
return; return;
...@@ -254,7 +254,7 @@ export class ExtensionsActivator { ...@@ -254,7 +254,7 @@ export class ExtensionsActivator {
let dep = this._activatedExtensions[depId]; let dep = this._activatedExtensions[depId];
if (dep.activationFailed) { if (dep.activationFailed) {
// Error condition 2: a dependency has already failed activation // Error condition 2: a dependency has already failed activation
this._host.showMessage(Severity.Error, nls.localize('failedDep1', "Extension '{1}' failed to activate. Reason: dependency '{0}' failed to activate.", depId, currentExtension.id)); this._host.showMessage(Severity.Error, nls.localize('failedDep1', "Cannot activate extension '{0}' as the depending extension '{1}' is failed to activate.", currentExtension.displayName || currentExtension.id, depId));
const error = new Error(`Dependency ${depId} failed to activate`); const error = new Error(`Dependency ${depId} failed to activate`);
(<any>error).detail = dep.activationFailedError; (<any>error).detail = dep.activationFailedError;
this._activatedExtensions[currentExtension.id] = new FailedExtension(error); this._activatedExtensions[currentExtension.id] = new FailedExtension(error);
......
...@@ -672,7 +672,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService, ...@@ -672,7 +672,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
location: ProgressLocation.Extensions, location: ProgressLocation.Extensions,
title: nls.localize('installingVSIXExtension', 'Installing extension from VSIX...'), title: nls.localize('installingVSIXExtension', 'Installing extension from VSIX...'),
source: `${extension}` source: `${extension}`
}, () => this.extensionService.install(URI.file(extension)).then(() => null)); }, () => this.extensionService.install(URI.file(extension)).then(extensionIdentifier => this.checkAndEnableDisabledDependencies(extensionIdentifier)));
} }
if (!(extension instanceof Extension)) { if (!(extension instanceof Extension)) {
...@@ -694,7 +694,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService, ...@@ -694,7 +694,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
location: ProgressLocation.Extensions, location: ProgressLocation.Extensions,
title: nls.localize('installingMarketPlaceExtension', 'Installing extension from Marketplace....'), title: nls.localize('installingMarketPlaceExtension', 'Installing extension from Marketplace....'),
source: `${extension.id}` source: `${extension.id}`
}, () => this.extensionService.installFromGallery(gallery)); }, () => this.extensionService.installFromGallery(gallery).then(() => this.checkAndEnableDisabledDependencies(gallery.identifier)));
} }
setEnablement(extensions: IExtension | IExtension[], enablementState: EnablementState): TPromise<void> { setEnablement(extensions: IExtension | IExtension[], enablementState: EnablementState): TPromise<void> {
...@@ -740,6 +740,17 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService, ...@@ -740,6 +740,17 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
}, () => TPromise.join(toReinstall.map(local => this.extensionService.reinstallFromGallery(local))).then(() => null)); }, () => TPromise.join(toReinstall.map(local => this.extensionService.reinstallFromGallery(local))).then(() => null));
} }
private checkAndEnableDisabledDependencies(extensionIdentifier: IExtensionIdentifier): TPromise<void> {
const extension = this.local.filter(e => areSameExtensions(extensionIdentifier, e.local.identifier))[0];
if (extension) {
const disabledDepencies = this.getExtensionsRecursively([extension], this.local, EnablementState.Enabled, { dependencies: true, pack: false });
if (disabledDepencies.length) {
return this.setEnablement(disabledDepencies, EnablementState.Enabled);
}
}
return TPromise.as(null);
}
private promptAndSetEnablement(extensions: IExtension[], enablementState: EnablementState): TPromise<any> { private promptAndSetEnablement(extensions: IExtension[], enablementState: EnablementState): TPromise<any> {
const enable = enablementState === EnablementState.Enabled || enablementState === EnablementState.WorkspaceEnabled; const enable = enablementState === EnablementState.Enabled || enablementState === EnablementState.WorkspaceEnabled;
if (enable) { if (enable) {
...@@ -759,7 +770,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService, ...@@ -759,7 +770,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
const enable = enablementState === EnablementState.Enabled || enablementState === EnablementState.WorkspaceEnabled; const enable = enablementState === EnablementState.Enabled || enablementState === EnablementState.WorkspaceEnabled;
if (!enable) { if (!enable) {
for (const extension of extensions) { for (const extension of extensions) {
let dependents = this.getDependentsAfterDisablement(extension, allExtensions, this.local, enablementState); let dependents = this.getDependentsAfterDisablement(extension, allExtensions, this.local);
if (dependents.length) { if (dependents.length) {
return TPromise.wrapError<void>(new Error(this.getDependentsErrorMessage(extension, allExtensions, dependents))); return TPromise.wrapError<void>(new Error(this.getDependentsErrorMessage(extension, allExtensions, dependents)));
} }
...@@ -797,7 +808,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService, ...@@ -797,7 +808,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
return []; return [];
} }
private getDependentsAfterDisablement(extension: IExtension, extensionsToDisable: IExtension[], installed: IExtension[], enablementState: EnablementState): IExtension[] { private getDependentsAfterDisablement(extension: IExtension, extensionsToDisable: IExtension[], installed: IExtension[]): IExtension[] {
return installed.filter(i => { return installed.filter(i => {
if (i.dependencies.length === 0) { if (i.dependencies.length === 0) {
return false; return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册