mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
Change onDidChangeTab event
This commit is contained in:
@@ -201,7 +201,7 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
private readonly _proxy: MainThreadEditorTabsShape;
|
||||
private readonly _onDidChangeTabs = new Emitter<vscode.Tab[]>();
|
||||
private readonly _onDidChangeTabs = new Emitter<vscode.TabChangeEvent>();
|
||||
private readonly _onDidChangeTabGroups = new Emitter<vscode.TabGroup[]>();
|
||||
|
||||
// Have to use ! because this gets initialized via an RPC proxy
|
||||
@@ -291,9 +291,30 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
|
||||
throw new Error('Update Tabs IPC call received before group creation.');
|
||||
}
|
||||
const tab = group.acceptTabOperation(operation);
|
||||
// We don't want to fire a change event with a closed tab to prevent an invalid tabs from being received
|
||||
if (operation.kind !== TabModelOperationKind.TAB_CLOSE) {
|
||||
this._onDidChangeTabs.fire([tab.apiObject]);
|
||||
|
||||
// Construct the tab change event based on the operation
|
||||
switch (operation.kind) {
|
||||
case TabModelOperationKind.TAB_OPEN:
|
||||
this._onDidChangeTabs.fire({
|
||||
added: [tab.apiObject],
|
||||
removed: [],
|
||||
changed: []
|
||||
});
|
||||
return;
|
||||
case TabModelOperationKind.TAB_CLOSE:
|
||||
this._onDidChangeTabs.fire({
|
||||
added: [],
|
||||
removed: [tab.apiObject],
|
||||
changed: []
|
||||
});
|
||||
return;
|
||||
case TabModelOperationKind.TAB_UPDATE:
|
||||
this._onDidChangeTabs.fire({
|
||||
added: [],
|
||||
removed: [],
|
||||
changed: [tab.apiObject]
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -361,7 +361,7 @@ suite('ExtHostEditorTabs', function () {
|
||||
|
||||
const tab = extHostEditorTabs.tabGroups.groups[0].tabs[0];
|
||||
|
||||
const p = new Promise<readonly vscode.Tab[]>(resolve => extHostEditorTabs.tabGroups.onDidChangeTabs(resolve));
|
||||
const p = new Promise<vscode.TabChangeEvent>(resolve => extHostEditorTabs.tabGroups.onDidChangeTabs(resolve));
|
||||
|
||||
extHostEditorTabs.$acceptTabOperation({
|
||||
groupId: 12,
|
||||
@@ -370,7 +370,7 @@ suite('ExtHostEditorTabs', function () {
|
||||
tabDto: { ...tabDto, label: 'NEW LABEL' }
|
||||
});
|
||||
|
||||
const changedTab = (await p)[0];
|
||||
const changedTab = (await p).changed[0];
|
||||
|
||||
assert.ok(tab === changedTab);
|
||||
assert.strictEqual(changedTab.label, 'NEW LABEL');
|
||||
|
||||
Reference in New Issue
Block a user