mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Fix #55072
This commit is contained in:
parent
7987bbfa20
commit
1762c10b65
|
@ -536,7 +536,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
|||
.then(installed => {
|
||||
const promises = installed
|
||||
.filter(e => e.manifest.publisher === extension.manifest.publisher && e.manifest.name === extension.manifest.name)
|
||||
.map(e => this.checkForDependenciesAndUninstall(e, installed, force));
|
||||
.map(e => this.checkForDependenciesAndUninstall(e, installed));
|
||||
return TPromise.join(promises).then(() => null, error => TPromise.wrapError(this.joinErrors(error)));
|
||||
}));
|
||||
}
|
||||
|
@ -593,23 +593,14 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
|||
}, new Error(''));
|
||||
}
|
||||
|
||||
private checkForDependenciesAndUninstall(extension: ILocalExtension, installed: ILocalExtension[], force: boolean): TPromise<void> {
|
||||
private checkForDependenciesAndUninstall(extension: ILocalExtension, installed: ILocalExtension[]): TPromise<void> {
|
||||
return this.preUninstallExtension(extension)
|
||||
.then(() => {
|
||||
const packedExtensions = this.getAllPackExtensionsToUninstall(extension, installed);
|
||||
if (packedExtensions.length) {
|
||||
return this.uninstallExtensions(extension, packedExtensions, installed);
|
||||
}
|
||||
const dependencies = this.getDependenciesToUninstall(extension, installed);
|
||||
if (dependencies.length) {
|
||||
if (force) {
|
||||
return this.uninstallExtensions(extension, dependencies, installed);
|
||||
} else {
|
||||
return this.promptForDependenciesAndUninstall(extension, dependencies, installed);
|
||||
}
|
||||
} else {
|
||||
return this.uninstallExtensions(extension, [], installed);
|
||||
}
|
||||
return this.uninstallExtensions(extension, [], installed);
|
||||
})
|
||||
.then(() => this.postUninstallExtension(extension),
|
||||
error => {
|
||||
|
@ -618,26 +609,6 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
|||
});
|
||||
}
|
||||
|
||||
private promptForDependenciesAndUninstall(extension: ILocalExtension, dependencies: ILocalExtension[], installed: ILocalExtension[]): TPromise<void> {
|
||||
const message = nls.localize('uninstallDependeciesConfirmation', "Also uninstall the dependencies of the extension '{0}'?", extension.manifest.displayName || extension.manifest.name);
|
||||
const buttons = [
|
||||
nls.localize('yes', "Yes"),
|
||||
nls.localize('no', "No"),
|
||||
nls.localize('cancel', "Cancel")
|
||||
];
|
||||
return this.dialogService.show(Severity.Info, message, buttons, { cancelId: 2 })
|
||||
.then<void>(value => {
|
||||
if (value === 0) {
|
||||
return this.uninstallExtensions(extension, dependencies, installed);
|
||||
}
|
||||
if (value === 1) {
|
||||
return this.uninstallExtensions(extension, [], installed);
|
||||
}
|
||||
this.logService.info('Cancelled uninstalling extension:', extension.identifier.id);
|
||||
return TPromise.wrapError(errors.canceled());
|
||||
}, error => TPromise.wrapError(errors.canceled()));
|
||||
}
|
||||
|
||||
private uninstallExtensions(extension: ILocalExtension, otherExtensionsToUninstall: ILocalExtension[], installed: ILocalExtension[]): TPromise<void> {
|
||||
const dependents = this.getDependents(extension, installed);
|
||||
if (dependents.length) {
|
||||
|
@ -662,38 +633,6 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
|||
extension.manifest.displayName || extension.manifest.name, dependents[0].manifest.displayName || dependents[0].manifest.name, dependents[1].manifest.displayName || dependents[1].manifest.name);
|
||||
}
|
||||
|
||||
private getDependenciesToUninstall(extension: ILocalExtension, installed: ILocalExtension[]): ILocalExtension[] {
|
||||
const dependencies = this.getAllDependenciesToUninstall(extension, installed).filter(e => e !== extension);
|
||||
|
||||
const dependenciesToUninstall = dependencies.slice(0);
|
||||
for (let index = 0; index < dependencies.length; index++) {
|
||||
const dep = dependencies[index];
|
||||
const dependents = this.getDependents(dep, installed);
|
||||
// Remove the dependency from the uninstall list if there is a dependent which will not be uninstalled.
|
||||
if (dependents.some(e => e !== extension && dependencies.indexOf(e) === -1)) {
|
||||
dependenciesToUninstall.splice(index - (dependencies.length - dependenciesToUninstall.length), 1);
|
||||
}
|
||||
}
|
||||
|
||||
return dependenciesToUninstall;
|
||||
}
|
||||
|
||||
private getAllDependenciesToUninstall(extension: ILocalExtension, installed: ILocalExtension[], checked: ILocalExtension[] = []): ILocalExtension[] {
|
||||
if (checked.indexOf(extension) !== -1) {
|
||||
return [];
|
||||
}
|
||||
checked.push(extension);
|
||||
if (!extension.manifest.extensionDependencies || extension.manifest.extensionDependencies.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const dependenciesToUninstall = installed.filter(i => extension.manifest.extensionDependencies.some(id => areSameExtensions({ id }, i.galleryIdentifier)));
|
||||
const depsOfDeps = [];
|
||||
for (const dep of dependenciesToUninstall) {
|
||||
depsOfDeps.push(...this.getAllDependenciesToUninstall(dep, installed, checked));
|
||||
}
|
||||
return [...dependenciesToUninstall, ...depsOfDeps];
|
||||
}
|
||||
|
||||
private getAllPackExtensionsToUninstall(extension: ILocalExtension, installed: ILocalExtension[], checked: ILocalExtension[] = []): ILocalExtension[] {
|
||||
if (checked.indexOf(extension) !== -1) {
|
||||
return [];
|
||||
|
|
|
@ -33,7 +33,6 @@ import { ExtensionsInput } from 'vs/workbench/parts/extensions/common/extensions
|
|||
import product from 'vs/platform/node/product';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IProgressService2, ProgressLocation } from 'vs/workbench/services/progress/common/progress';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { groupBy } from 'vs/base/common/collections';
|
||||
|
@ -385,7 +384,6 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
|
|||
@IExtensionGalleryService private galleryService: IExtensionGalleryService,
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@ITelemetryService private telemetryService: ITelemetryService,
|
||||
@IDialogService private dialogService: IDialogService,
|
||||
@INotificationService private notificationService: INotificationService,
|
||||
@IURLService urlService: IURLService,
|
||||
@IExtensionEnablementService private extensionEnablementService: IExtensionEnablementService,
|
||||
|
@ -751,34 +749,10 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
|
|||
if (packedExtensions.length) {
|
||||
return this.checkAndSetEnablement(extensions, packedExtensions, enablementState);
|
||||
}
|
||||
const dependencies = this.getExtensionsRecursively(extensions, this.local, enablementState, { dependencies: true, pack: false });
|
||||
if (dependencies.length) {
|
||||
return this.promptForDependenciesAndDisable(extensions, dependencies, enablementState);
|
||||
} else {
|
||||
return this.checkAndSetEnablement(extensions, [], enablementState);
|
||||
}
|
||||
return this.checkAndSetEnablement(extensions, [], enablementState);
|
||||
}
|
||||
}
|
||||
|
||||
private promptForDependenciesAndDisable(extensions: IExtension[], dependencies: IExtension[], enablementState: EnablementState): TPromise<void> {
|
||||
const message = extensions.length > 1 ? nls.localize('disableDependeciesConfirmation', "Also disable the dependencies of the extensions?") : nls.localize('disableDependeciesSingleExtensionConfirmation', "Also disable the dependencies of the extension '{0}'?", extensions[0].displayName);
|
||||
const buttons = [
|
||||
nls.localize('yes', "Yes"),
|
||||
nls.localize('cancel', "Cancel"),
|
||||
nls.localize('no', "No"),
|
||||
];
|
||||
return this.dialogService.show(Severity.Info, message, buttons, { cancelId: 2 })
|
||||
.then<void>(value => {
|
||||
if (value === 0) {
|
||||
return this.checkAndSetEnablement(extensions, dependencies, enablementState);
|
||||
}
|
||||
if (value === 2) {
|
||||
return this.checkAndSetEnablement(extensions, [], enablementState);
|
||||
}
|
||||
return TPromise.as(null);
|
||||
});
|
||||
}
|
||||
|
||||
private checkAndSetEnablement(extensions: IExtension[], otherExtensions: IExtension[], enablementState: EnablementState): TPromise<any> {
|
||||
const allExtensions = [...extensions, ...otherExtensions];
|
||||
const enable = enablementState === EnablementState.Enabled || enablementState === EnablementState.WorkspaceEnabled;
|
||||
|
|
Loading…
Reference in a new issue