mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Add model change events separate from group
This commit is contained in:
parent
6d7222d524
commit
82b8de69a7
|
@ -87,6 +87,9 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
private readonly _onWillDispose = this._register(new Emitter<void>());
|
||||
readonly onWillDispose = this._onWillDispose.event;
|
||||
|
||||
private readonly _onDidModelChange = this._register(new Emitter<IGroupChangeEvent>());
|
||||
readonly onDidModelChange = this._onDidModelChange.event;
|
||||
|
||||
private readonly _onDidGroupChange = this._register(new Emitter<IGroupChangeEvent>());
|
||||
readonly onDidGroupChange = this._onDidGroupChange.event;
|
||||
|
||||
|
@ -529,6 +532,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
this._register(this.model.onDidMoveEditor(event => this.onDidMoveEditor(event)));
|
||||
this._register(this.model.onDidOpenEditor(editor => this.onDidOpenEditor(editor)));
|
||||
this._register(this.model.onDidCloseEditor(editor => this.handleOnDidCloseEditor(editor)));
|
||||
this._register(this.model.onDidActivateEditor(editor => this._onDidModelChange.fire({ kind: GroupChangeKind.EDITOR_ACTIVE, editor })));
|
||||
this._register(this.model.onWillDisposeEditor(editor => this.onWillDisposeEditor(editor)));
|
||||
this._register(this.model.onDidChangeEditorDirty(editor => this.onDidChangeEditorDirty(editor)));
|
||||
this._register(this.model.onDidChangeEditorLabel(editor => this.onDidChangeEditorLabel(editor)));
|
||||
|
@ -543,18 +547,22 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
|
||||
private onDidChangeGroupLocked(): void {
|
||||
this._onDidGroupChange.fire({ kind: GroupChangeKind.GROUP_LOCKED });
|
||||
this._onDidModelChange.fire({ kind: GroupChangeKind.GROUP_LOCKED });
|
||||
}
|
||||
|
||||
private onDidChangeEditorPinned(editor: EditorInput): void {
|
||||
this._onDidGroupChange.fire({ kind: GroupChangeKind.EDITOR_PIN, editor });
|
||||
this._onDidModelChange.fire({ kind: GroupChangeKind.EDITOR_PIN, editor });
|
||||
}
|
||||
|
||||
private onDidChangeEditorSticky(editor: EditorInput): void {
|
||||
this._onDidGroupChange.fire({ kind: GroupChangeKind.EDITOR_STICKY, editor });
|
||||
this._onDidModelChange.fire({ kind: GroupChangeKind.EDITOR_STICKY, editor });
|
||||
}
|
||||
|
||||
private onDidMoveEditor({ editor, index, newIndex }: IEditorMoveEvent): void {
|
||||
this._onDidGroupChange.fire({ kind: GroupChangeKind.EDITOR_MOVE, editor, oldEditorIndex: index, editorIndex: newIndex });
|
||||
this._onDidModelChange.fire({ kind: GroupChangeKind.EDITOR_MOVE, editor, oldEditorIndex: index, editorIndex: newIndex });
|
||||
}
|
||||
|
||||
private onDidOpenEditor({ editor, index }: IEditorOpenEvent): void {
|
||||
|
@ -573,6 +581,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
|
||||
// Event
|
||||
this._onDidGroupChange.fire({ kind: GroupChangeKind.EDITOR_OPEN, editor, editorIndex: index });
|
||||
this._onDidModelChange.fire({ kind: GroupChangeKind.EDITOR_OPEN, editor, editorIndex: index });
|
||||
}
|
||||
|
||||
private handleOnDidCloseEditor(event: IEditorCloseEvent): void {
|
||||
|
@ -614,6 +623,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
// Event
|
||||
this._onDidCloseEditor.fire(event);
|
||||
this._onDidGroupChange.fire({ kind: GroupChangeKind.EDITOR_CLOSE, editor, editorIndex: event.index });
|
||||
this._onDidModelChange.fire({ kind: GroupChangeKind.EDITOR_CLOSE, editor, editorIndex: event.index });
|
||||
}
|
||||
|
||||
private canDispose(editor: EditorInput): boolean {
|
||||
|
@ -794,6 +804,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
if (this._index !== newIndex) {
|
||||
this._index = newIndex;
|
||||
this._onDidGroupChange.fire({ kind: GroupChangeKind.GROUP_INDEX });
|
||||
this._onDidModelChange.fire({ kind: GroupChangeKind.GROUP_INDEX });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -147,14 +147,13 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
|||
private registerGroupListeners(group: IEditorGroupView): void {
|
||||
const groupDisposables = new DisposableStore();
|
||||
|
||||
groupDisposables.add(group.onDidGroupChange(e => {
|
||||
// Here we only really care about model change events
|
||||
groupDisposables.add(group.onDidModelChange(e => {
|
||||
switch (e.kind) {
|
||||
case GroupChangeKind.EDITOR_ACTIVE:
|
||||
if (group.activeEditor) {
|
||||
this._onDidEditorsChange.fire([{ groupId: group.id, editor: group.activeEditor, kind: GroupChangeKind.EDITOR_ACTIVE }]);
|
||||
}
|
||||
this.handleActiveEditorChange(group);
|
||||
this._onDidVisibleEditorsChange.fire();
|
||||
break;
|
||||
default:
|
||||
this._onDidEditorsChange.fire([{ groupId: group.id, ...e }]);
|
||||
|
@ -162,6 +161,13 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
|||
}
|
||||
}));
|
||||
|
||||
groupDisposables.add(group.onDidGroupChange(e => {
|
||||
if (e.kind === GroupChangeKind.EDITOR_ACTIVE) {
|
||||
this.handleActiveEditorChange(group);
|
||||
this._onDidVisibleEditorsChange.fire();
|
||||
}
|
||||
}));
|
||||
|
||||
groupDisposables.add(group.onDidCloseEditor(event => {
|
||||
this._onDidCloseEditor.fire(event);
|
||||
}));
|
||||
|
|
|
@ -455,6 +455,13 @@ export interface IEditorGroup {
|
|||
*/
|
||||
readonly onDidGroupChange: Event<IGroupChangeEvent>;
|
||||
|
||||
/**
|
||||
* An aggregated event that fires whenever the model changes in any way.
|
||||
* This is very similar to `onDidGroupChange` except its specifically
|
||||
* for things whihc would affect the model. Primarily used for the tabs API
|
||||
*/
|
||||
readonly onDidModelChange: Event<IGroupChangeEvent>;
|
||||
|
||||
/**
|
||||
* An event that is fired when the group gets disposed.
|
||||
*/
|
||||
|
|
|
@ -798,6 +798,7 @@ export class TestEditorGroupView implements IEditorGroupView {
|
|||
|
||||
onWillDispose: Event<void> = Event.None;
|
||||
onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
|
||||
onDidModelChange: Event<IGroupChangeEvent> = Event.None;
|
||||
onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
|
||||
onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
|
||||
onDidOpenEditorFail: Event<EditorInput> = Event.None;
|
||||
|
|
Loading…
Reference in a new issue