tabs - move move into TabGroups

This commit is contained in:
Johannes
2022-03-18 14:27:37 +01:00
parent 897c851383
commit c385364f5d
5 changed files with 27 additions and 22 deletions

View File

@@ -391,7 +391,7 @@ suite('vscode API - window', () => {
const group2Tabs = tabGroups.groups[1].tabs;
assert.strictEqual(group2Tabs.length, 1);
await group1Tabs[0].move(1, ViewColumn.One);
await tabGroups.move(group1Tabs[0], ViewColumn.One, 1);
});
// TODO @lramos15 re-enable these once shape is more stable

View File

@@ -382,7 +382,7 @@ export class MainThreadEditorTabs implements MainThreadEditorTabsShape {
}
}
//#region Messages received from Ext Host
$moveTab(tabId: string, index: number, viewColumn: EditorGroupColumn): void {
$moveTab(tabId: string, index: number, viewColumn: EditorGroupColumn, preserveFocus?: boolean): void {
const groupId = columnToEditorGroup(this._editorGroupsService, viewColumn);
const tabInfo = this._tabInfoLookup.get(tabId);
const tab = tabInfo?.tab;
@@ -414,7 +414,7 @@ export class MainThreadEditorTabs implements MainThreadEditorTabsShape {
return;
}
// Move the editor to the target group
sourceGroup.moveEditor(editorInput, targetGroup, { index, preserveFocus: true });
sourceGroup.moveEditor(editorInput, targetGroup, { index, preserveFocus });
return;
}

View File

@@ -657,7 +657,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): void;
$moveTab(tabId: string, index: number, viewColumn: EditorGroupColumn, preserveFocus?: boolean): void;
$closeTab(tabIds: string[], preserveFocus?: boolean): Promise<void>;
}

View File

@@ -25,11 +25,9 @@ class ExtHostEditorTab {
private _apiObject: vscode.Tab | undefined;
private _dto!: IEditorTabDto;
private _input: AnyTabInput | undefined;
private readonly _proxy: MainThreadEditorTabsShape;
private readonly _activeTabIdGetter: () => string;
constructor(dto: IEditorTabDto, proxy: MainThreadEditorTabsShape, activeTabIdGetter: () => string) {
this._proxy = proxy;
constructor(dto: IEditorTabDto, activeTabIdGetter: () => string) {
this._activeTabIdGetter = activeTabIdGetter;
this.acceptDtoUpdate(dto);
}
@@ -57,10 +55,6 @@ class ExtHostEditorTab {
},
get viewColumn() {
return typeConverters.ViewColumn.to(that._dto.viewColumn);
},
move: async (index: number, viewColumn: ViewColumn) => {
this._proxy.$moveTab(that._dto.id, index, typeConverters.ViewColumn.from(viewColumn));
return;
}
});
}
@@ -110,7 +104,7 @@ class ExtHostEditorTabGroup {
if (tabDto.isActive) {
this._activeTabId = tabDto.id;
}
this._tabs.push(new ExtHostEditorTab(tabDto, proxy, () => this.activeTabId()));
this._tabs.push(new ExtHostEditorTab(tabDto, () => this.activeTabId()));
}
}
@@ -206,6 +200,14 @@ class ExtHostTabGroups {
}
this._proxy.$closeTab(extHostTabIds, preserveFocus);
return;
},
move: async (tab: vscode.Tab, viewColumn: ViewColumn, index: number, preservceFocus?: boolean) => {
const extHostTab = this.findExtHostTabFromApi(tab);
if (!extHostTab) {
throw new Error('Invalid tab');
}
this._proxy.$moveTab(extHostTab.tabId, index, typeConverters.ViewColumn.from(viewColumn), preservceFocus);
return;
}
});
}

View File

@@ -72,16 +72,6 @@ declare module 'vscode' {
* Whether or not the tab is pinned
*/
readonly isPinned: boolean;
/**
* Moves a tab to the given index within the column.
* If the index is out of range, the tab will be moved to the end of the column.
* If the column is out of range, a new one will be created after the last existing column.
* @param index The index to move the tab to
* @param viewColumn The column to move the tab into
*/
// TODO@API move into TabGroups
move(index: number, viewColumn: ViewColumn): Thenable<void>;
}
export namespace window {
@@ -143,5 +133,18 @@ declare module 'vscode' {
*/
close(tab: Tab[], preserveFocus?: boolean): Thenable<void>;
close(tab: Tab, preserveFocus?: boolean): Thenable<void>;
/**
* Moves a tab to the given index within the column.
* If the index is out of range, the tab will be moved to the end of the column.
* If the column is out of range, a new one will be created after the last existing column.
*
* @package tab The tab to move.
* @param viewColumn The column to move the tab into
* @param index The index to move the tab to
*/
// TODO@API support TabGroup in addition to ViewColumn
// TODO@API support just index for moving inside current group
move(tab: Tab, viewColumn: ViewColumn, index: number, preserveFocus?: boolean): Thenable<void>;
}
}