提交 f1add038 编写于 作者: B Benjamin Pasero

try to get rid of editor input changing event

上级 02970ec5
......@@ -121,7 +121,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
this.panelHeight = this.storageService.getInteger(WorkbenchLayout.sashYHeightSettingsKey, StorageScope.GLOBAL, 0);
this.toUnbind.push(themeService.onDidThemeChange(_ => this.relayout()));
this.toUnbind.push(eventService.addListener2(EventType.EDITOR_INPUT_CHANGING, () => this.onEditorInputChanging()));
this.toUnbind.push(eventService.addListener2(EventType.EDITOR_INPUT_CHANGED, () => this.onEditorInputChanged()));
this.registerSashListeners();
}
......@@ -243,7 +243,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
});
}
private onEditorInputChanging(): void {
private onEditorInputChanged(): void {
// Make sure that we layout properly in case we detect that the sidebar is large enought to cause
// multiple opened editors to go below minimal size. The fix is to trigger a layout for any editor
......
......@@ -363,14 +363,10 @@ export class EditorPart extends Part implements IEditorPart {
}
private doSetInput(group: EditorGroup, editor: BaseEditor, input: EditorInput, options: EditorOptions, monitor: ProgressMonitor): TPromise<BaseEditor> {
let position = this.stacks.positionOfGroup(group);
// Emit Input-Changed Event as appropiate
const previousInput = editor.getInput();
const inputChanged = (!previousInput || !previousInput.matches(input) || (options && options.forceOpen));
if (inputChanged) {
this.emit(WorkbenchEventType.EDITOR_INPUT_CHANGING, new EditorEvent(editor, input, options, position));
}
// Call into Editor
let timerEvent = timer.start(timer.Topic.WORKBENCH, strings.format('Set Editor Input: {0}', input.getName()));
......@@ -523,9 +519,6 @@ export class EditorPart extends Part implements IEditorPart {
// Update stacks model
this.modifyGroups(() => this.stacks.closeGroup(group));
// Emit Input-Changing Event
this.emit(WorkbenchEventType.EDITOR_INPUT_CHANGING, new EditorEvent(null, null, null, position));
// Hide Editor
this.doHideEditor(position, true);
......@@ -812,7 +805,6 @@ export class EditorPart extends Part implements IEditorPart {
// Emit as editor input change event so that clients get aware of new active editor
let activeEditor = this.sideBySideControl.getActiveEditor();
if (activeEditor) {
this.emit(WorkbenchEventType.EDITOR_INPUT_CHANGING, new EditorEvent(activeEditor));
this.emit(WorkbenchEventType.EDITOR_INPUT_CHANGED, new EditorEvent(activeEditor));
}
......
......@@ -124,7 +124,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
public create(): void {
// Listen on Editor Input Changes to show in MRU List
this.toUnbind.push(this.eventService.addListener2(EventType.EDITOR_INPUT_CHANGING, (e: EditorEvent) => this.onEditorInputChanging(e)));
this.toUnbind.push(this.eventService.addListener2(EventType.EDITOR_INPUT_CHANGED, (e: EditorEvent) => this.onEditorInputChanged(e)));
this.toUnbind.push(this.eventService.addListener2(EventType.EDITOR_SET_INPUT_ERROR, (e: EditorInputEvent) => this.onEditorInputSetError(e)));
// Editor History Model
......@@ -135,7 +135,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
}
}
private onEditorInputChanging(e: EditorEvent): void {
private onEditorInputChanged(e: EditorEvent): void {
if (e.editorInput) {
// If an active editor is set, but is different from the one from the event, return early
......
......@@ -32,15 +32,6 @@ export class EventType {
*/
static EDITOR_INPUT_OPENING = 'editorInputOpening';
/**
* Event type for when the editor input is about to change. This event is being sent before (!) the input is being set
* to the active editor. Use EDITOR_INPUT_CHANGED to react after the input has been set and displayed by the editor.
*
* Note: This event will also be emitted when multiple editors are open and the user sets focus from the active editor
* to another one. This allows to detect a focus change of the active editor.
*/
static EDITOR_INPUT_CHANGING = 'editorInputChanging';
/**
* Event type for when the editor input has been changed in the currently active editor. This event is being sent after
* the input has been set and displayed by the editor.
......
......@@ -140,14 +140,14 @@ export class ExplorerView extends CollapsibleViewletView {
return this.doRefresh().then(() => {
// When the explorer viewer is loaded, listen to changes to the editor input
this.toDispose.push(this.eventService.addListener2(WorkbenchEventType.EDITOR_INPUT_CHANGING, (e: EditorEvent) => this.onEditorInputChanging(e)));
this.toDispose.push(this.eventService.addListener2(WorkbenchEventType.EDITOR_INPUT_CHANGED, (e: EditorEvent) => this.onEditorInputChanged(e)));
// Also handle configuration updates
this.toDispose.push(this.configurationService.onDidUpdateConfiguration(e => this.onConfigurationUpdated(e.config, true)));
});
}
private onEditorInputChanging(e: EditorEvent): void {
private onEditorInputChanged(e: EditorEvent): void {
// During workbench startup, the editor area might restore more than one editor from a previous
// session. When this happens there might be editor input changing events for side editors that
......
......@@ -241,7 +241,7 @@ suite('Workbench QuickOpen', () => {
let cinput1 = <EditorInput>inst.createInstance(fileInputCtor, toResource('Hello World'), 'text/plain', null);
let event = new EditorEvent(null, cinput1, null, Position.LEFT);
eventService.emit(EventType.EDITOR_INPUT_CHANGING, event);
eventService.emit(EventType.EDITOR_INPUT_CHANGED, event);
assert.equal(1, controller.getEditorHistoryModel().getEntries().length);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册