diff --git a/src/vs/workbench/browser/parts/editor/textEditor.ts b/src/vs/workbench/browser/parts/editor/textEditor.ts index 1c3e842e785ffede7e7e9abb68549122dc3b2136..08870420bc3d34848398fbbf9603f0fc3798a099 100644 --- a/src/vs/workbench/browser/parts/editor/textEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textEditor.ts @@ -139,7 +139,8 @@ export abstract class BaseTextEditor extends BaseEditor { * provide their own editor control that should be used (e.g. a DiffEditor). */ public createEditorControl(parent: Builder): IEditor { - return this._instantiationService.createInstance(CodeEditor, parent.getHTMLElement(), this.getCodeEditorOptions()); + // Use a getter for the instantiation service since some subclasses might use scoped instantiation services + return this.instantiationService.createInstance(CodeEditor, parent.getHTMLElement(), this.getCodeEditorOptions()); } public setInput(input: EditorInput, options: EditorOptions): TPromise { diff --git a/src/vs/workbench/parts/output/browser/outputPanel.ts b/src/vs/workbench/parts/output/browser/outputPanel.ts index 4447939aef20b72f00c79cb25c26e019ac85fa66..390428c617853222bc537a76916fcba0e3b64fa9 100644 --- a/src/vs/workbench/parts/output/browser/outputPanel.ts +++ b/src/vs/workbench/parts/output/browser/outputPanel.ts @@ -16,6 +16,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { IEventService } from 'vs/platform/event/common/event'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IMessageService } from 'vs/platform/message/common/message'; +import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { EditorInput, EditorOptions } from 'vs/workbench/common/editor'; import { StringEditor } from 'vs/workbench/browser/parts/editor/stringEditor'; @@ -31,6 +32,7 @@ export class OutputPanel extends StringEditor { private toDispose: lifecycle.IDisposable[]; private actions: IAction[]; + private scopedInstantiationService: IInstantiationService; constructor( @ITelemetryService telemetryService: ITelemetryService, @@ -48,6 +50,7 @@ export class OutputPanel extends StringEditor { ) { super(telemetryService, instantiationService, contextService, storageService, messageService, configurationService, eventService, editorService, themeService, untitledEditorService); + this.scopedInstantiationService = instantiationService; this.toDispose = []; } @@ -100,14 +103,20 @@ export class OutputPanel extends StringEditor { } public createEditor(parent: Builder): void { - super.createEditor(parent); - const scopedContextKeyService = this.contextKeyService.createScoped(this.getContainer().getHTMLElement()); + // First create the scoped instantation service and only then construct the editor using the scoped service + const scopedContextKeyService = this.contextKeyService.createScoped(parent.getHTMLElement()); this.toDispose.push(scopedContextKeyService); - CONTEXT_IN_OUTPUT.bindTo(scopedContextKeyService).set(true); + this.scopedInstantiationService = this.instantiationService.createChild(new ServiceCollection([IContextKeyService, scopedContextKeyService])); + super.createEditor(parent); + CONTEXT_IN_OUTPUT.bindTo(scopedContextKeyService).set(true); this.setInput(OutputEditorInput.getInstance(this.instantiationService, this.outputService.getActiveChannel()), null); } + public get instantiationService(): IInstantiationService { + return this.scopedInstantiationService; + } + public dispose(): void { this.toDispose = lifecycle.dispose(this.toDispose); super.dispose();