From f1add038136be0cd6a97b833d92a975a18922693 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 1 Jun 2016 11:06:11 +0200 Subject: [PATCH] try to get rid of editor input changing event --- src/vs/workbench/browser/layout.ts | 4 ++-- src/vs/workbench/browser/parts/editor/editorPart.ts | 8 -------- .../browser/parts/quickopen/quickOpenController.ts | 4 ++-- src/vs/workbench/common/events.ts | 9 --------- .../workbench/parts/files/browser/views/explorerView.ts | 4 ++-- .../test/browser/parts/quickOpen/quickopen.test.ts | 2 +- 6 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index aec08830fc6..bee81b6633b 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -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 diff --git a/src/vs/workbench/browser/parts/editor/editorPart.ts b/src/vs/workbench/browser/parts/editor/editorPart.ts index 046a3366522..518845b7c7f 100644 --- a/src/vs/workbench/browser/parts/editor/editorPart.ts +++ b/src/vs/workbench/browser/parts/editor/editorPart.ts @@ -363,14 +363,10 @@ export class EditorPart extends Part implements IEditorPart { } private doSetInput(group: EditorGroup, editor: BaseEditor, input: EditorInput, options: EditorOptions, monitor: ProgressMonitor): TPromise { - 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)); } diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index ec5fd102e48..335cf147cfd 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -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 diff --git a/src/vs/workbench/common/events.ts b/src/vs/workbench/common/events.ts index 27aa32bc206..b7e0b21bd51 100644 --- a/src/vs/workbench/common/events.ts +++ b/src/vs/workbench/common/events.ts @@ -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. diff --git a/src/vs/workbench/parts/files/browser/views/explorerView.ts b/src/vs/workbench/parts/files/browser/views/explorerView.ts index 4f8250d531c..265c2be9ada 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerView.ts @@ -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 diff --git a/src/vs/workbench/test/browser/parts/quickOpen/quickopen.test.ts b/src/vs/workbench/test/browser/parts/quickOpen/quickopen.test.ts index aa619ee01fe..3bdd44455b3 100644 --- a/src/vs/workbench/test/browser/parts/quickOpen/quickopen.test.ts +++ b/src/vs/workbench/test/browser/parts/quickOpen/quickopen.test.ts @@ -241,7 +241,7 @@ suite('Workbench QuickOpen', () => { let cinput1 = 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); -- GitLab