This commit is contained in:
Logan Ramos 2022-03-28 14:36:35 -04:00
parent fd7f35aa4c
commit 64f37bc300
No known key found for this signature in database
GPG key ID: D9CCFF14F0B18183
5 changed files with 13 additions and 7 deletions

View file

@ -473,7 +473,7 @@ export class MainThreadEditorTabs implements MainThreadEditorTabsShape {
return;
}
async $closeTab(tabIds: string[], preserveFocus?: boolean): Promise<void> {
async $closeTab(tabIds: string[], preserveFocus?: boolean): Promise<boolean> {
const groups: Map<IEditorGroup, EditorInput[]> = new Map();
for (const tabId of tabIds) {
const tabInfo = this._tabInfoLookup.get(tabId);
@ -492,9 +492,12 @@ export class MainThreadEditorTabs implements MainThreadEditorTabsShape {
}
}
// Loop over keys of the groups map and call closeEditors
let results: boolean[] = [];
for (const [group, editors] of groups) {
await group.closeEditors(editors, { preserveFocus });
results.push(await group.closeEditors(editors, { preserveFocus }));
}
// TODO @jrieken This isn't quite right how can we say true for some but not others?
return results.every(result => result);
}
//#endregion
}

View file

@ -668,7 +668,7 @@ export type AnyInputDto = UnknownInputDto | TextInputDto | TextDiffInputDto | No
export interface MainThreadEditorTabsShape extends IDisposable {
// manage tabs: move, close, rearrange etc
$moveTab(tabId: string, index: number, viewColumn: EditorGroupColumn, preserveFocus?: boolean): void;
$closeTab(tabIds: string[], preserveFocus?: boolean): Promise<void>;
$closeTab(tabIds: string[], preserveFocus?: boolean): Promise<boolean>;
}
export interface IEditorTabGroupDto {

View file

@ -219,8 +219,7 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
}
extHostTabIds.push(extHostTab.tabId);
}
this._proxy.$closeTab(extHostTabIds, preserveFocus);
return;
return this._proxy.$closeTab(extHostTabIds, preserveFocus);
},
move: async (tab: vscode.Tab, viewColumn: ViewColumn, index: number, preservceFocus?: boolean) => {
const extHostTab = this._findExtHostTabFromApi(tab);

View file

@ -350,6 +350,7 @@ suite('ExtHostEditorTabs', function () {
// override/implement $moveTab or $closeTab
override async $closeTab(tabIds: string[], preserveFocus?: boolean) {
closedTabIds.push(tabIds);
return true;
}
})
);
@ -387,6 +388,7 @@ suite('ExtHostEditorTabs', function () {
// override/implement $moveTab or $closeTab
override async $closeTab(tabIds: string[], preserveFocus?: boolean) {
closedTabIds.push(tabIds);
return true;
}
})
);

View file

@ -157,9 +157,11 @@ declare module 'vscode' {
* Note: In the case of a dirty tab, a confirmation dialog will be shown which may be cancelled. If cancelled the tab is still valid
* @param tab The tab to close, must be reference equal to a tab given by the API
* @param preserveFocus When `true` focus will remain in its current position. If `false` it will jump to the next tab.
* @returns A promise that resolves true when then tab is closed. Otherwise it will return false.
* If false is returned the tab is still valid.
*/
close(tab: Tab[], preserveFocus?: boolean): Thenable<void>;
close(tab: Tab, preserveFocus?: boolean): Thenable<void>;
close(tab: Tab[], preserveFocus?: boolean): Thenable<boolean>;
close(tab: Tab, preserveFocus?: boolean): Thenable<boolean>;
/**
* Moves a tab to the given index within the column.