Skip to content

Commit 15ec907

Browse files
committed
Have onDidChangeTab return an array
1 parent 46abb2b commit 15ec907

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

src/vs/workbench/api/common/extHostEditorTabs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
177177
readonly _serviceBrand: undefined;
178178

179179
private readonly _proxy: MainThreadEditorTabsShape;
180-
private readonly _onDidChangeTab = new Emitter<vscode.Tab>();
180+
private readonly _onDidChangeTab = new Emitter<vscode.Tab[]>();
181181
private readonly _onDidChangeTabGroup = new Emitter<void>();
182182
private readonly _onDidChangeActiveTabGroup = new Emitter<vscode.TabGroup>();
183183

@@ -199,7 +199,7 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
199199
// never changes -> simple value
200200
onDidChangeTabGroup: that._onDidChangeTabGroup.event,
201201
onDidChangeActiveTabGroup: that._onDidChangeActiveTabGroup.event,
202-
onDidChangeTab: that._onDidChangeTab.event,
202+
onDidChangeTabs: that._onDidChangeTab.event,
203203
// dynamic -> getters
204204
get groups() {
205205
return Object.freeze(that._extHostTabGroups.map(group => group.apiObject));
@@ -284,6 +284,6 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
284284
throw new Error('Update Tabs IPC call received before group creation.');
285285
}
286286
const tab = group.acceptTabDtoUpdate(tabDto);
287-
this._onDidChangeTab.fire(tab.apiObject);
287+
this._onDidChangeTab.fire([tab.apiObject]);
288288
}
289289
}

src/vs/workbench/api/test/browser/extHostEditorTabs.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,11 @@ suite('ExtHostEditorTabs', function () {
413413

414414
const tab = extHostEditorTabs.tabGroups.groups[0].tabs[0];
415415

416-
const p = new Promise<vscode.Tab>(resolve => extHostEditorTabs.tabGroups.onDidChangeTab(resolve));
416+
const p = new Promise<vscode.Tab[]>(resolve => extHostEditorTabs.tabGroups.onDidChangeTabs(resolve));
417417

418418
extHostEditorTabs.$acceptTabUpdate(12, { ...tabDto, label: 'NEW LABEL' });
419419

420-
const changedTab = await p;
420+
const changedTab = (await p)[0];
421421

422422
assert.ok(tab === changedTab);
423423
assert.strictEqual(changedTab.label, 'NEW LABEL');

src/vscode-dts/vscode.proposed.tabs.d.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ declare module 'vscode' {
5454
*/
5555
export interface Tab {
5656

57-
// TODO@API consider adding:
58-
// readonly index: number;
59-
6057
/**
6158
* The text displayed on the tab
6259
*/
@@ -146,15 +143,12 @@ declare module 'vscode' {
146143
/**
147144
* An {@link Event} which fires when a tab changes.
148145
*/
149-
// TODO@API use richer event type?
150-
// TODO@API future proof: event with an array of tab-instances
151-
readonly onDidChangeTab: Event<Tab>;
146+
readonly onDidChangeTabs: Event<Tab[]>;
152147

153148
/**
154149
* An {@link Event} which fires when the active group changes.
155150
* This does not fire when the properties within the group change.
156151
*/
157-
// TODO@API consider to replace with onDidChangeActiveTAB (group can be inferred from that)
158152
readonly onDidChangeActiveTabGroup: Event<TabGroup>;
159153

160154
/**

0 commit comments

Comments
 (0)