From 28cf60f25ad4dc33421b3f4320f1e33be0e689fb Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 26 Oct 2016 11:41:15 +0200 Subject: [PATCH] output: first create the scoped instantation service and only then construct the editor using it fixes #13463 fixes #12263 --- .../workbench/browser/parts/editor/textEditor.ts | 3 ++- .../workbench/parts/output/browser/outputPanel.ts | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/textEditor.ts b/src/vs/workbench/browser/parts/editor/textEditor.ts index 1c3e842e785..08870420bc3 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 4447939aef2..390428c6178 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(); -- GitLab