This commit is contained in:
Sandeep Somavarapu 2019-07-22 18:01:34 +02:00
parent 21c19f759c
commit 8007de3602
3 changed files with 25 additions and 11 deletions

View file

@ -1200,7 +1200,7 @@ export class ReloadAction extends ExtensionAction {
const isSameExtensionRunning = runningExtension && this.extension.server === this.extensionManagementServerService.getExtensionManagementServer(runningExtension.extensionLocation);
if (isUninstalled) {
if (isSameExtensionRunning) {
if (isSameExtensionRunning && !this.extensionService.canRemoveExtension(runningExtension)) {
this.enabled = true;
this.label = localize('reloadRequired', "Reload Required");
this.tooltip = localize('postUninstallTooltip', "Please reload Visual Studio Code to complete the uninstallation of this extension.");

View file

@ -1160,15 +1160,29 @@ suite('ExtensionsActions Test', () => {
const extensions = await instantiationService.get(IExtensionsWorkbenchService).queryLocal();
testObject.extension = extensions[0];
return new Promise(c => {
testObject.onDidChange(() => {
if (testObject.enabled && testObject.tooltip === 'Please reload Visual Studio Code to complete the uninstallation of this extension.') {
c();
}
});
uninstallEvent.fire(local.identifier);
didUninstallEvent.fire({ identifier: local.identifier });
uninstallEvent.fire(local.identifier);
didUninstallEvent.fire({ identifier: local.identifier });
assert.ok(testObject.enabled);
assert.equal(testObject.tooltip, 'Please reload Visual Studio Code to complete the uninstallation of this extension.');
});
test('Test ReloadAction when extension is uninstalled and can be removed', async () => {
const local = aLocalExtension('a');
instantiationService.stub(IExtensionService, <Partial<IExtensionService>>{
getExtensions: () => Promise.resolve([ExtensionsActions.toExtensionDescription(local)]),
onDidChangeExtensions: new Emitter<void>().event,
canRemoveExtension: (extension) => true,
canAddExtension: (extension) => true
});
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
instantiationService.createInstance(ExtensionContainers, [testObject]);
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
const extensions = await instantiationService.get(IExtensionsWorkbenchService).queryLocal();
testObject.extension = extensions[0];
uninstallEvent.fire(local.identifier);
didUninstallEvent.fire({ identifier: local.identifier });
assert.ok(!testObject.enabled);
});
test('Test ReloadAction when extension is uninstalled and installed', async () => {

View file

@ -203,6 +203,8 @@ export class ExtensionService extends AbstractExtensionService implements IExten
// Update the local registry
const result = this._registry.deltaExtensions(toAdd, toRemove.map(e => e.identifier));
this._onDidChangeExtensions.fire(undefined);
toRemove = toRemove.concat(result.removedDueToLooping);
if (result.removedDueToLooping.length > 0) {
this._logOrShowMessage(Severity.Error, nls.localize('looping', "The following extensions contain dependency loops and have been disabled: {0}", result.removedDueToLooping.map(e => `'${e.identifier.value}'`).join(', ')));
@ -219,8 +221,6 @@ export class ExtensionService extends AbstractExtensionService implements IExten
await this._extensionHostProcessManagers[0].deltaExtensions(toAdd, toRemove.map(e => e.identifier));
}
this._onDidChangeExtensions.fire(undefined);
for (let i = 0; i < toAdd.length; i++) {
this._activateAddedExtensionIfNeeded(toAdd[i]);
}