@@ -253,6 +253,7 @@ export class TabsMainImpl implements TabsMain, Disposable {
253253 private onTabClosed ( tabInfo : TabInfo , title : Title < Widget > ) : void {
254254 tabInfo . group . tabs . splice ( tabInfo . tabIndex , 1 ) ;
255255 this . tabInfoLookup . delete ( title ) ;
256+ this . updateTabIndices ( this . applicationShell . getTabBarFor ( title . owner ) ) ;
256257 this . proxy . $acceptTabOperation ( {
257258 kind : TabModelOperationKind . TAB_CLOSE ,
258259 index : tabInfo . tabIndex ,
@@ -267,6 +268,7 @@ export class TabsMainImpl implements TabsMain, Disposable {
267268 const tabDto = this . createTabDto ( args . title , tabInfo . group . groupId ) ;
268269 tabInfo . group . tabs . splice ( args . fromIndex , 1 ) ;
269270 tabInfo . group . tabs . splice ( args . toIndex , 0 , tabDto ) ;
271+ this . updateTabIndices ( tabBar ) ;
270272 this . proxy . $acceptTabOperation ( {
271273 kind : TabModelOperationKind . TAB_MOVE ,
272274 index : args . toIndex ,
@@ -290,6 +292,17 @@ export class TabsMainImpl implements TabsMain, Disposable {
290292 return ;
291293 }
292294
295+ updateTabIndices ( tabBar ?: TabBar < Widget > ) : void {
296+ if ( tabBar ) {
297+ tabBar . titles . forEach ( ( title , index ) => {
298+ const tabInfo = this . tabInfoLookup . get ( title ) ;
299+ if ( tabInfo ) {
300+ tabInfo . tabIndex = index ;
301+ }
302+ } ) ;
303+ }
304+ }
305+
293306 async $closeTab ( tabIds : string [ ] , preserveFocus ?: boolean ) : Promise < boolean > {
294307 const widgets : Widget [ ] = [ ] ;
295308 for ( const tabId of tabIds ) {
0 commit comments