@@ -419,13 +419,16 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
419419 // Mark preferred size as changed
420420 this . resetPreferredSize ( ) ;
421421
422- // Events for groupd that got added
422+ // Events for groups that got added
423423 this . getGroups ( GroupsOrder . GRID_APPEARANCE ) . forEach ( groupView => {
424424 if ( currentGroupViews . indexOf ( groupView ) === - 1 ) {
425425 this . _onDidAddGroup . fire ( groupView ) ;
426426 }
427427 } ) ;
428428
429+ // Update labels
430+ this . updateGroupLabels ( ) ;
431+
429432 // Restore focus as needed
430433 if ( gridHasFocus ) {
431434 this . _activeGroup . focus ( ) ;
@@ -475,6 +478,9 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
475478 // Event
476479 this . _onDidAddGroup . fire ( newGroupView ) ;
477480
481+ // Update labels
482+ this . updateGroupLabels ( ) ;
483+
478484 return newGroupView ;
479485 }
480486
@@ -631,12 +637,8 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
631637 this . _activeGroup . focus ( ) ;
632638 }
633639
634- // Update labels: since our labels are created using the index of the
635- // group, removing a group might produce gaps. So we iterate over all
636- // groups and reassign the label based on the index.
637- this . getGroups ( GroupsOrder . CREATION_TIME ) . forEach ( ( group , index ) => {
638- group . setLabel ( this . getGroupLabel ( index + 1 ) ) ;
639- } ) ;
640+ // Update labels
641+ this . updateGroupLabels ( ) ;
640642
641643 // Update container
642644 this . updateContainer ( ) ;
@@ -648,10 +650,6 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
648650 this . _onDidRemoveGroup . fire ( groupView ) ;
649651 }
650652
651- private getGroupLabel ( index : number ) : string {
652- return localize ( 'groupLabel' , "Group {0}" , index ) ;
653- }
654-
655653 moveGroup ( group : IEditorGroupView | GroupIdentifier , location : IEditorGroupView | GroupIdentifier , direction : GroupDirection ) : IEditorGroupView {
656654 const sourceView = this . assertGroupView ( group ) ;
657655 const targetView = this . assertGroupView ( location ) ;
@@ -887,6 +885,21 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
887885 toggleClass ( this . container , 'empty' , this . isEmpty ( ) ) ;
888886 }
889887
888+ private updateGroupLabels ( ) : void {
889+
890+ // Since our labels are created using the index of the
891+ // group, adding/removing a group might produce gaps.
892+ // So we iterate over all groups and reassign the label
893+ // based on the index.
894+ this . getGroups ( GroupsOrder . GRID_APPEARANCE ) . forEach ( ( group , index ) => {
895+ group . setLabel ( this . getGroupLabel ( index + 1 ) ) ;
896+ } ) ;
897+ }
898+
899+ private getGroupLabel ( index : number ) : string {
900+ return localize ( 'groupLabel' , "Group {0}" , index ) ;
901+ }
902+
890903 private isEmpty ( ) : boolean {
891904 return this . groupViews . size === 1 && this . _activeGroup . isEmpty ( ) ;
892905 }
0 commit comments