diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index 7b70edcd88a1401d63d3a7d8e88f55293aa6bb49..258ffbab5d360f4c9bb0cb432e4546bb60cb3134 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -288,8 +288,13 @@ export class WorkbenchShell { this.toUnbind.push(lifecycleService.onShutdown(() => disposables.dispose())); serviceCollection.set(ILifecycleService, lifecycleService); + const extensionManagementChannel = getDelayedChannel(sharedProcess.then(c => c.getChannel('extensions'))); + const extensionManagementChannelClient = new ExtensionManagementChannelClient(extensionManagementChannel); + serviceCollection.set(IExtensionManagementService, extensionManagementChannelClient); + const extensionsRuntimeService = instantiationService.createInstance(ExtensionsRuntimeService); serviceCollection.set(IExtensionsRuntimeService, extensionsRuntimeService); + disposables.add(extensionsRuntimeService); const extensionHostProcessWorker = this.startExtensionHost(instantiationService); this.threadService = instantiationService.createInstance(MainThreadService, extensionHostProcessWorker.messagingProtocol); @@ -333,10 +338,6 @@ export class WorkbenchShell { const integrityService = instantiationService.createInstance(IntegrityServiceImpl); serviceCollection.set(IIntegrityService, integrityService); - const extensionManagementChannel = getDelayedChannel(sharedProcess.then(c => c.getChannel('extensions'))); - const extensionManagementChannelClient = new ExtensionManagementChannelClient(extensionManagementChannel); - serviceCollection.set(IExtensionManagementService, extensionManagementChannelClient); - const urlChannel = mainProcessClient.getChannel('url'); const urlChannelClient = new URLChannelClient(urlChannel, this.windowService.getWindowId()); serviceCollection.set(IURLService, urlChannelClient); diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts index 575549dafc585b440e3443d35bcec970ec2d4d06..594e5047227a88ba2c83829943578eef9855830e 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts @@ -627,7 +627,6 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService { if (!error) { this.unInstalled.push(uninstalling.extension); - this.extensionsRuntimeService.setEnablement(uninstalling.extension.identifier, true); uninstalling.extension.needsReload = !newlyInstalled; this.reportTelemetry(uninstalling, true); } diff --git a/src/vs/workbench/services/extensions/electron-browser/extensions.ts b/src/vs/workbench/services/extensions/electron-browser/extensions.ts index ff33be2e2ef2402ed8bc2c332ae326d32445934f..c57b12fb2e4d3bd5a71dc6caaaec7811a912d2e4 100644 --- a/src/vs/workbench/services/extensions/electron-browser/extensions.ts +++ b/src/vs/workbench/services/extensions/electron-browser/extensions.ts @@ -9,7 +9,9 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { distinct } from 'vs/base/common/arrays'; import * as paths from 'vs/base/common/paths'; import URI from 'vs/base/common/uri'; +import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { ExtensionScanner, MessagesCollector } from 'vs/workbench/node/extensionPoints'; +import { IExtensionManagementService, DidUninstallExtensionEvent } from 'vs/platform/extensionManagement/common/extensionManagement'; import { IWorkspaceContextService, IWorkspace } from 'vs/platform/workspace/common/workspace'; import { IExtensionsRuntimeService, IExtensionDescription, IMessage } from 'vs/platform/extensions/common/extensions'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; @@ -29,17 +31,20 @@ export class ExtensionsRuntimeService implements IExtensionsRuntimeService { private workspace: IWorkspace; private installedExtensions: TPromise; - private _globalDisabledExtensions: string[]; private _workspaceDisabledExtensions: string[]; + private disposables: IDisposable[] = []; + constructor( @IStorageService private storageService: IStorageService, @IWorkspaceContextService contextService: IWorkspaceContextService, @IMessageService private messageService: IMessageService, - @IEnvironmentService private environmentService: IEnvironmentService + @IEnvironmentService private environmentService: IEnvironmentService, + @IExtensionManagementService private extensionManagementService: IExtensionManagementService ) { this.workspace = contextService.getWorkspace(); + extensionManagementService.onDidUninstallExtension(this.onDidUninstallExtension, this, this.disposables); } public getExtensions(includeDisabled: boolean = false): TPromise { @@ -163,6 +168,14 @@ export class ExtensionsRuntimeService implements IExtensionsRuntimeService { } } + private onDidUninstallExtension({id, error}: DidUninstallExtensionEvent): void { + if (!error) { + id = stripVersion(id); + this.enableExtension(id, StorageScope.WORKSPACE); + this.enableExtension(id, StorageScope.GLOBAL); + } + } + private scanExtensions(): TPromise { const collector = new MessagesCollector(); const version = pkg.version; @@ -226,4 +239,12 @@ export class ExtensionsRuntimeService implements IExtensionsRuntimeService { } } } + + dispose(): void { + this.disposables = dispose(this.disposables); + } +} + +function stripVersion(id: string): string { + return id.replace(/-\d+\.\d+\.\d+$/, ''); } \ No newline at end of file