提交 28cf60f2 编写于 作者: I isidor

output: first create the scoped instantation service and only then construct the editor using it

fixes #13463
fixes #12263
上级 10730bf0
...@@ -139,7 +139,8 @@ export abstract class BaseTextEditor extends BaseEditor { ...@@ -139,7 +139,8 @@ export abstract class BaseTextEditor extends BaseEditor {
* provide their own editor control that should be used (e.g. a DiffEditor). * provide their own editor control that should be used (e.g. a DiffEditor).
*/ */
public createEditorControl(parent: Builder): IEditor { 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<void> { public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
......
...@@ -16,6 +16,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur ...@@ -16,6 +16,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { IEventService } from 'vs/platform/event/common/event'; import { IEventService } from 'vs/platform/event/common/event';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IMessageService } from 'vs/platform/message/common/message'; 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 { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { EditorInput, EditorOptions } from 'vs/workbench/common/editor'; import { EditorInput, EditorOptions } from 'vs/workbench/common/editor';
import { StringEditor } from 'vs/workbench/browser/parts/editor/stringEditor'; import { StringEditor } from 'vs/workbench/browser/parts/editor/stringEditor';
...@@ -31,6 +32,7 @@ export class OutputPanel extends StringEditor { ...@@ -31,6 +32,7 @@ export class OutputPanel extends StringEditor {
private toDispose: lifecycle.IDisposable[]; private toDispose: lifecycle.IDisposable[];
private actions: IAction[]; private actions: IAction[];
private scopedInstantiationService: IInstantiationService;
constructor( constructor(
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
...@@ -48,6 +50,7 @@ export class OutputPanel extends StringEditor { ...@@ -48,6 +50,7 @@ export class OutputPanel extends StringEditor {
) { ) {
super(telemetryService, instantiationService, contextService, storageService, super(telemetryService, instantiationService, contextService, storageService,
messageService, configurationService, eventService, editorService, themeService, untitledEditorService); messageService, configurationService, eventService, editorService, themeService, untitledEditorService);
this.scopedInstantiationService = instantiationService;
this.toDispose = []; this.toDispose = [];
} }
...@@ -100,14 +103,20 @@ export class OutputPanel extends StringEditor { ...@@ -100,14 +103,20 @@ export class OutputPanel extends StringEditor {
} }
public createEditor(parent: Builder): void { public createEditor(parent: Builder): void {
super.createEditor(parent); // First create the scoped instantation service and only then construct the editor using the scoped service
const scopedContextKeyService = this.contextKeyService.createScoped(this.getContainer().getHTMLElement()); const scopedContextKeyService = this.contextKeyService.createScoped(parent.getHTMLElement());
this.toDispose.push(scopedContextKeyService); 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); this.setInput(OutputEditorInput.getInstance(this.instantiationService, this.outputService.getActiveChannel()), null);
} }
public get instantiationService(): IInstantiationService {
return this.scopedInstantiationService;
}
public dispose(): void { public dispose(): void {
this.toDispose = lifecycle.dispose(this.toDispose); this.toDispose = lifecycle.dispose(this.toDispose);
super.dispose(); super.dispose();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册