From a98e2df0beefa5d022c8d855020535f409bc0d26 Mon Sep 17 00:00:00 2001 From: Jonah Iden Date: Wed, 12 Apr 2023 09:44:45 +0200 Subject: [PATCH] fixed #12392. Tab indices now updated after deleting and moving a tab Signed-off-by: Jonah Iden --- .../plugin-ext/src/main/browser/tabs/tabs-main.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/plugin-ext/src/main/browser/tabs/tabs-main.ts b/packages/plugin-ext/src/main/browser/tabs/tabs-main.ts index 63c3e567e06df..71dea114665bb 100644 --- a/packages/plugin-ext/src/main/browser/tabs/tabs-main.ts +++ b/packages/plugin-ext/src/main/browser/tabs/tabs-main.ts @@ -253,6 +253,7 @@ export class TabsMainImpl implements TabsMain, Disposable { private onTabClosed(tabInfo: TabInfo, title: Title): 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, @@ -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, @@ -290,6 +292,17 @@ export class TabsMainImpl implements TabsMain, Disposable { return; } + updateTabIndices(tabBar?: TabBar): 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 { const widgets: Widget[] = []; for (const tabId of tabIds) {