mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
add TabGroupChangeEvent-event which is similar to the TabChangeEvent (#147443)
This commit is contained in:
@@ -12,6 +12,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
|
||||
import { CustomEditorTabInput, NotebookDiffEditorTabInput, NotebookEditorTabInput, TerminalEditorTabInput, TextDiffTabInput, TextTabInput, ViewColumn, WebviewEditorTabInput } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
import { assertIsDefined } from 'vs/base/common/types';
|
||||
import { diffSets } from 'vs/base/common/collections';
|
||||
|
||||
export interface IExtHostEditorTabs extends IExtHostEditorTabsShape {
|
||||
readonly _serviceBrand: undefined;
|
||||
@@ -213,7 +214,7 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
|
||||
|
||||
private readonly _proxy: MainThreadEditorTabsShape;
|
||||
private readonly _onDidChangeTabs = new Emitter<vscode.TabChangeEvent>();
|
||||
private readonly _onDidChangeTabGroups = new Emitter<vscode.TabGroup[]>();
|
||||
private readonly _onDidChangeTabGroups = new Emitter<vscode.TabGroupChangeEvent>();
|
||||
|
||||
// Have to use ! because this gets initialized via an RPC proxy
|
||||
private _activeGroupId!: number;
|
||||
@@ -271,8 +272,22 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
|
||||
|
||||
$acceptEditorTabModel(tabGroups: IEditorTabGroupDto[]): void {
|
||||
|
||||
const groupIdsBefore = new Set(this._extHostTabGroups.map(group => group.groupId));
|
||||
const groupIdsAfter = new Set(tabGroups.map(dto => dto.groupId));
|
||||
const diff = diffSets(groupIdsBefore, groupIdsAfter);
|
||||
|
||||
const closed: vscode.TabGroup[] = this._extHostTabGroups.filter(group => diff.removed.includes(group.groupId)).map(group => group.apiObject);
|
||||
const opened: vscode.TabGroup[] = [];
|
||||
const changed: vscode.TabGroup[] = [];
|
||||
|
||||
|
||||
this._extHostTabGroups = tabGroups.map(tabGroup => {
|
||||
const group = new ExtHostEditorTabGroup(tabGroup, this._proxy, () => this._activeGroupId);
|
||||
if (diff.added.includes(group.groupId)) {
|
||||
opened.push(group.apiObject);
|
||||
} else {
|
||||
changed.push(group.apiObject);
|
||||
}
|
||||
return group;
|
||||
});
|
||||
|
||||
@@ -281,7 +296,7 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
|
||||
if (activeTabGroupId !== undefined && this._activeGroupId !== activeTabGroupId) {
|
||||
this._activeGroupId = activeTabGroupId;
|
||||
}
|
||||
this._onDidChangeTabGroups.fire(this._extHostTabGroups.map(g => g.apiObject));
|
||||
this._onDidChangeTabGroups.fire(Object.freeze({ opened, closed, changed }));
|
||||
}
|
||||
|
||||
$acceptTabGroupUpdate(groupDto: IEditorTabGroupDto) {
|
||||
@@ -293,7 +308,7 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
|
||||
if (groupDto.isActive) {
|
||||
this._activeGroupId = groupDto.groupId;
|
||||
}
|
||||
this._onDidChangeTabGroups.fire([group.apiObject]);
|
||||
this._onDidChangeTabGroups.fire(Object.freeze({ changed: [group.apiObject], opened: [], closed: [] }));
|
||||
}
|
||||
|
||||
$acceptTabOperation(operation: TabOperation) {
|
||||
|
||||
Reference in New Issue
Block a user