提交 3f446e49 编写于 作者: J Johannes Rieken

hidden editor shouldn't listen to events, #9705

上级 dc5d20e3
......@@ -230,6 +230,7 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom
this._configuration.updateOptions(newOptions);
this._editorReadonly.set(this._configuration.editor.readOnly);
this._editorTabMovesFocusKey.set(this._configuration.editor.tabFocusMode);
console.log(this.getId(), newOptions.readOnly, this._configuration.editor.readOnly, this._configuration.editor.tabFocusMode);
}
public getConfiguration(): editorCommon.InternalEditorOptions {
......
......@@ -8,6 +8,7 @@
import {TPromise} from 'vs/base/common/winjs.base';
import {Dimension, Builder} from 'vs/base/browser/builder';
import objects = require('vs/base/common/objects');
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
import {CodeEditorWidget} from 'vs/editor/browser/widget/codeEditorWidget';
import {OptionsChangeEvent, EventType as WorkbenchEventType} from 'vs/workbench/common/events';
import {EditorInput, EditorOptions} from 'vs/workbench/common/editor';
......@@ -35,6 +36,7 @@ import {Selection} from 'vs/editor/common/core/selection';
export abstract class BaseTextEditor extends BaseEditor {
private editorControl: IEditor;
private _editorContainer: Builder;
private _disposeOnInputChange: IDisposable[] = [];
constructor(
id: string,
......@@ -50,11 +52,6 @@ export abstract class BaseTextEditor extends BaseEditor {
@IThemeService private _themeService: IThemeService
) {
super(id, telemetryService);
this.toUnbind.push(this._eventService.addListener2(WorkbenchEventType.WORKBENCH_OPTIONS_CHANGED, (e) => this.onOptionsChanged(e)));
this.toUnbind.push(this.configurationService.onDidUpdateConfiguration(e => this.applyConfiguration(e.config)));
this.toUnbind.push(_themeService.onDidThemeChange(_ => this.onThemeChanged()));
}
public get instantiationService(): IInstantiationService {
......@@ -73,6 +70,14 @@ export abstract class BaseTextEditor extends BaseEditor {
return this._messageService;
}
private hookConfigurationListeners(): void {
if (this._disposeOnInputChange.length === 0) {
this._disposeOnInputChange.push(this._eventService.addListener2(WorkbenchEventType.WORKBENCH_OPTIONS_CHANGED, (e) => this.onOptionsChanged(e)));
this._disposeOnInputChange.push(this.configurationService.onDidUpdateConfiguration(e => this.applyConfiguration(e.config)));
this._disposeOnInputChange.push(this._themeService.onDidThemeChange(_ => this.onThemeChanged()));
}
}
protected applyConfiguration(configuration: IFilesConfiguration): void {
// Update Editor with configuration and editor settings
......@@ -141,11 +146,19 @@ export abstract class BaseTextEditor extends BaseEditor {
}
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
this.hookConfigurationListeners();
return super.setInput(input, options).then(() => {
this.editorControl.updateOptions(this.getCodeEditorOptions()); // support input specific editor options
});
}
public clearInput(): void {
this._disposeOnInputChange = dispose(this._disposeOnInputChange);
return super.clearInput();
}
public setEditorVisible(visible: boolean, position: Position = null): void {
// Pass on to Editor
......@@ -178,6 +191,8 @@ export abstract class BaseTextEditor extends BaseEditor {
public dispose(): void {
dispose(this._disposeOnInputChange);
// Destroy Editor Control
this.editorControl.destroy();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册