未验证 提交 2225e94a 编写于 作者: S Sandeep Somavarapu 提交者: GitHub

Trigger extension change event immediately after updating exte… (#77767)

Trigger extension change event immediately after updating extensions
......@@ -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.");
......
......@@ -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 () => {
......
......@@ -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]);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册