Skip to content

Commit

Permalink
fixed #12392. Tab indices now updated
Browse files Browse the repository at this point in the history
after deleting and moving a tab

Signed-off-by: Jonah Iden <jonah.iden@typefox.io>
  • Loading branch information
jonah-iden committed Apr 12, 2023
1 parent 9952221 commit a98e2df
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/plugin-ext/src/main/browser/tabs/tabs-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export class TabsMainImpl implements TabsMain, Disposable {
private onTabClosed(tabInfo: TabInfo, title: Title<Widget>): void {
tabInfo.group.tabs.splice(tabInfo.tabIndex, 1);
this.tabInfoLookup.delete(title);
this.updateTabIndices(this.applicationShell.getTabBarFor(title.owner));
this.proxy.$acceptTabOperation({
kind: TabModelOperationKind.TAB_CLOSE,
index: tabInfo.tabIndex,
Expand All @@ -267,6 +268,7 @@ export class TabsMainImpl implements TabsMain, Disposable {
const tabDto = this.createTabDto(args.title, tabInfo.group.groupId);
tabInfo.group.tabs.splice(args.fromIndex, 1);
tabInfo.group.tabs.splice(args.toIndex, 0, tabDto);
this.updateTabIndices(tabBar);
this.proxy.$acceptTabOperation({
kind: TabModelOperationKind.TAB_MOVE,
index: args.toIndex,
Expand All @@ -290,6 +292,17 @@ export class TabsMainImpl implements TabsMain, Disposable {
return;
}

updateTabIndices(tabBar?: TabBar<Widget>): void {
if (tabBar) {
tabBar.titles.forEach((title, index) => {
const tabInfo = this.tabInfoLookup.get(title);
if (tabInfo) {
tabInfo.tabIndex = index;
}
});
}
}

async $closeTab(tabIds: string[], preserveFocus?: boolean): Promise<boolean> {
const widgets: Widget[] = [];
for (const tabId of tabIds) {
Expand Down

0 comments on commit a98e2df

Please sign in to comment.