This commit is contained in:
Logan Ramos 2022-03-15 09:55:57 -04:00
parent 037fd05f03
commit ed5a545047
No known key found for this signature in database
GPG key ID: D9CCFF14F0B18183
5 changed files with 8 additions and 11 deletions

View file

@ -1287,7 +1287,7 @@ export class Repository implements Disposable {
t.additionalResourcesAndViewTypes.find(r => r.resource!.scheme === 'git'))); t.additionalResourcesAndViewTypes.find(r => r.resource!.scheme === 'git')));
// Close editors // Close editors
diffEditorTabsToClose.forEach(t => t.close()); diffEditorTabsToClose.forEach(t => t.close(false));
} }
async branch(name: string, _checkout: boolean, _ref?: string): Promise<void> { async branch(name: string, _checkout: boolean, _ref?: string): Promise<void> {

View file

@ -349,7 +349,7 @@ export class MainThreadEditorTabs {
return; return;
} }
async $closeTab(tab: IEditorTabDto): Promise<void> { async $closeTab(tab: IEditorTabDto, preserveFocus: boolean): Promise<void> {
const group = this._editorGroupsService.getGroup(columnToEditorGroup(this._editorGroupsService, tab.viewColumn)); const group = this._editorGroupsService.getGroup(columnToEditorGroup(this._editorGroupsService, tab.viewColumn));
if (!group) { if (!group) {
return; return;
@ -359,7 +359,7 @@ export class MainThreadEditorTabs {
if (!editor) { if (!editor) {
return; return;
} }
await group.closeEditor(editor); await group.closeEditor(editor, { preserveFocus });
} }
//#endregion //#endregion
} }

View file

@ -612,7 +612,7 @@ export interface ExtHostEditorInsetsShape {
export interface MainThreadEditorTabsShape extends IDisposable { export interface MainThreadEditorTabsShape extends IDisposable {
// manage tabs: move, close, rearrange etc // manage tabs: move, close, rearrange etc
$moveTab(tab: IEditorTabDto, index: number, viewColumn: EditorGroupColumn): void; $moveTab(tab: IEditorTabDto, index: number, viewColumn: EditorGroupColumn): void;
$closeTab(tab: IEditorTabDto): Promise<void>; $closeTab(tab: IEditorTabDto, preserveFocus: boolean): Promise<void>;
} }
export interface IEditorTabGroupDto { export interface IEditorTabGroupDto {

View file

@ -22,7 +22,7 @@ export interface IEditorTab {
isDirty: boolean; isDirty: boolean;
additionalResourcesAndViewTypes: { resource: vscode.Uri | undefined; viewType: string | undefined }[]; additionalResourcesAndViewTypes: { resource: vscode.Uri | undefined; viewType: string | undefined }[];
move(index: number, viewColumn: ViewColumn): Promise<void>; move(index: number, viewColumn: ViewColumn): Promise<void>;
close(): Promise<void>; close(preserveFocus: boolean): Promise<void>;
} }
export interface IEditorTabGroup { export interface IEditorTabGroup {
@ -122,13 +122,11 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
move: async (index: number, viewColumn: ViewColumn) => { move: async (index: number, viewColumn: ViewColumn) => {
this._proxy.$moveTab(tabDto, index, typeConverters.ViewColumn.from(viewColumn)); this._proxy.$moveTab(tabDto, index, typeConverters.ViewColumn.from(viewColumn));
// TODO: Need an on did change tab event at the group level // TODO: Need an on did change tab event at the group level
// await raceTimeout(Event.toPromise(this._onDidChangeTabs.event), 1000);
return; return;
}, },
close: async () => { close: async (preserveFocus) => {
await this._proxy.$closeTab(tabDto); await this._proxy.$closeTab(tabDto, preserveFocus);
// TODO: Need an on did change tab event at the group level // TODO: Need an on did change tab event at the group level
// await raceTimeout(Event.toPromise(this._onDidChangeTabs.event), 1000);
return; return;
} }
}); });

View file

@ -87,8 +87,7 @@ declare module 'vscode' {
* should no longer be used for further actions. * should no longer be used for further actions.
*/ */
// TODO@API move into TabGroups, support one or many tabs or tab groups // TODO@API move into TabGroups, support one or many tabs or tab groups
// TODO@API add `preserveFocus` close(preserveFocus: boolean): Thenable<void>;
close(): Thenable<void>;
} }
export namespace window { export namespace window {