提交 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 {
* 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<void> {
......
......@@ -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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册