diff --git a/src/vs/workbench/api/browser/mainThreadEditorTabs.ts b/src/vs/workbench/api/browser/mainThreadEditorTabs.ts index 02eccc795a5..4ef7a11ea00 100644 --- a/src/vs/workbench/api/browser/mainThreadEditorTabs.ts +++ b/src/vs/workbench/api/browser/mainThreadEditorTabs.ts @@ -11,7 +11,7 @@ import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; import { EditorInput } from 'vs/workbench/common/editor/editorInput'; import { columnToEditorGroup, EditorGroupColumn, editorGroupToColumn } from 'vs/workbench/services/editor/common/editorGroupColumn'; import { GroupDirection, IEditorGroup, IEditorGroupsService, preferredSideBySideGroupDirection } from 'vs/workbench/services/editor/common/editorGroupsService'; -import { IEditorsChangeEvent, IEditorService, IEditorsMoveEvent, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService'; +import { IEditorsChangeEvent, IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService'; import { AbstractTextResourceEditorInput } from 'vs/workbench/common/editor/textResourceEditorInput'; import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebookEditorInput'; import { CustomEditorInput } from 'vs/workbench/contrib/customEditor/browser/customEditorInput'; @@ -21,6 +21,7 @@ import { TerminalEditorInput } from 'vs/workbench/contrib/terminal/browser/termi import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { SideBySideEditorInput } from 'vs/workbench/common/editor/sideBySideEditorInput'; import { isEqual } from 'vs/base/common/resources'; +import { isGroupEditorMoveEvent } from 'vs/workbench/common/editor/editorGroupModel'; interface TabInfo { tab: IEditorTabDto; @@ -469,10 +470,12 @@ export class MainThreadEditorTabs implements MainThreadEditorTabsShape { * The main handler for the tab events * @param events The list of events to process */ - private _updateTabsModel(event: IEditorsChangeEvent | IEditorsMoveEvent): void { + private _updateTabsModel(changeEvent: IEditorsChangeEvent): void { + const event = changeEvent.event; + const groupId = changeEvent.groupId; switch (event.kind) { case GroupModelChangeKind.GROUP_ACTIVE: - if (event.groupId === this._editorGroupsService.activeGroup.id) { + if (groupId === this._editorGroupsService.activeGroup.id) { this._onDidGroupActivate(); break; } else { @@ -480,42 +483,42 @@ export class MainThreadEditorTabs implements MainThreadEditorTabsShape { } case GroupModelChangeKind.EDITOR_LABEL: if (event.editor !== undefined && event.editorIndex !== undefined) { - this._onDidTabLabelChange(event.groupId, event.editor, event.editorIndex); + this._onDidTabLabelChange(groupId, event.editor, event.editorIndex); break; } case GroupModelChangeKind.EDITOR_OPEN: if (event.editor !== undefined && event.editorIndex !== undefined) { - this._onDidTabOpen(event.groupId, event.editor, event.editorIndex); + this._onDidTabOpen(groupId, event.editor, event.editorIndex); break; } case GroupModelChangeKind.EDITOR_CLOSE: if (event.editorIndex !== undefined) { - this._onDidTabClose(event.groupId, event.editorIndex); + this._onDidTabClose(groupId, event.editorIndex); break; } case GroupModelChangeKind.EDITOR_ACTIVE: if (event.editorIndex !== undefined) { - this._onDidTabActiveChange(event.groupId, event.editorIndex); + this._onDidTabActiveChange(groupId, event.editorIndex); break; } case GroupModelChangeKind.EDITOR_DIRTY: if (event.editorIndex !== undefined && event.editor !== undefined) { - this._onDidTabDirty(event.groupId, event.editorIndex, event.editor); + this._onDidTabDirty(groupId, event.editorIndex, event.editor); break; } case GroupModelChangeKind.EDITOR_STICKY: if (event.editorIndex !== undefined && event.editor !== undefined) { - this._onDidTabPinChange(event.groupId, event.editorIndex, event.editor); + this._onDidTabPinChange(groupId, event.editorIndex, event.editor); break; } case GroupModelChangeKind.EDITOR_PIN: if (event.editorIndex !== undefined && event.editor !== undefined) { - this._onDidTabPreviewChange(event.groupId, event.editorIndex, event.editor); + this._onDidTabPreviewChange(groupId, event.editorIndex, event.editor); break; } case GroupModelChangeKind.EDITOR_MOVE: - if (event.editor && event.editorIndex !== undefined && (event as IEditorsMoveEvent).oldEditorIndex !== undefined) { - this._onDidTabMove(event.groupId, event.editorIndex, (event as IEditorsMoveEvent).oldEditorIndex, event.editor); + if (isGroupEditorMoveEvent(event) && event.editor && event.editorIndex !== undefined && event.oldEditorIndex !== undefined) { + this._onDidTabMove(groupId, event.editorIndex, event.oldEditorIndex, event.editor); break; } default: diff --git a/src/vs/workbench/services/editor/browser/editorService.ts b/src/vs/workbench/services/editor/browser/editorService.ts index cc65731773c..4b5689f2e11 100644 --- a/src/vs/workbench/services/editor/browser/editorService.ts +++ b/src/vs/workbench/services/editor/browser/editorService.ts @@ -15,7 +15,7 @@ import { URI } from 'vs/base/common/uri'; import { joinPath } from 'vs/base/common/resources'; import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; import { IEditorGroupsService, IEditorGroup, GroupsOrder, IEditorReplacement, isEditorReplacement, ICloseEditorOptions } from 'vs/workbench/services/editor/common/editorGroupsService'; -import { IUntypedEditorReplacement, IEditorService, ISaveEditorsOptions, ISaveAllEditorsOptions, IRevertAllEditorsOptions, IBaseSaveRevertAllEditorOptions, IOpenEditorsOptions, PreferredGroup, isPreferredGroup, IEditorsChangeEvent, IEditorsMoveEvent } from 'vs/workbench/services/editor/common/editorService'; +import { IUntypedEditorReplacement, IEditorService, ISaveEditorsOptions, ISaveAllEditorsOptions, IRevertAllEditorsOptions, IBaseSaveRevertAllEditorOptions, IOpenEditorsOptions, PreferredGroup, isPreferredGroup, IEditorsChangeEvent } from 'vs/workbench/services/editor/common/editorService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { Disposable, IDisposable, dispose, DisposableStore } from 'vs/base/common/lifecycle'; import { coalesce, distinct } from 'vs/base/common/arrays'; @@ -47,7 +47,7 @@ export class EditorService extends Disposable implements EditorServiceImpl { private readonly _onDidVisibleEditorsChange = this._register(new Emitter()); readonly onDidVisibleEditorsChange = this._onDidVisibleEditorsChange.event; - private readonly _onDidEditorsChange = this._register(new Emitter()); + private readonly _onDidEditorsChange = this._register(new Emitter()); readonly onDidEditorsChange = this._onDidEditorsChange.event; private readonly _onDidCloseEditor = this._register(new Emitter()); @@ -148,7 +148,7 @@ export class EditorService extends Disposable implements EditorServiceImpl { const groupDisposables = new DisposableStore(); groupDisposables.add(group.onDidModelChange(e => { - this._onDidEditorsChange.fire({ groupId: group.id, ...e }); + this._onDidEditorsChange.fire({ groupId: group.id, event: e }); })); groupDisposables.add(group.onDidActiveEditorChange(() => { diff --git a/src/vs/workbench/services/editor/common/editorService.ts b/src/vs/workbench/services/editor/common/editorService.ts index 270e93b8bdf..32f2c303e1e 100644 --- a/src/vs/workbench/services/editor/common/editorService.ts +++ b/src/vs/workbench/services/editor/common/editorService.ts @@ -11,7 +11,7 @@ import { Event } from 'vs/base/common/event'; import { IEditor, IDiffEditor } from 'vs/editor/common/editorCommon'; import { ICloseEditorOptions, IEditorGroup, isEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService'; import { URI } from 'vs/base/common/uri'; -import { IGroupEditorMoveEvent, IGroupModelChangeEvent } from 'vs/workbench/common/editor/editorGroupModel'; +import { IGroupModelChangeEvent } from 'vs/workbench/common/editor/editorGroupModel'; export const IEditorService = createDecorator('editorService'); @@ -88,12 +88,15 @@ export interface IOpenEditorsOptions { readonly validateTrust?: boolean; } -export interface IEditorsChangeEvent extends IGroupModelChangeEvent { - groupId: GroupIdentifier; -} - -export interface IEditorsMoveEvent extends IGroupEditorMoveEvent { +export interface IEditorsChangeEvent { + /** + * The group which had the editor change + */ groupId: GroupIdentifier; + /* + * The event fired from the model + */ + event: IGroupModelChangeEvent; } export interface IEditorService {