@@ -815,11 +815,39 @@ class MultiRunTestDecoration extends RunTestDecoration implements ITestDecoratio
815
815
allActions . push ( new Action ( 'testing.gutter.debugAll' , localize ( 'debug all test' , 'Debug All Tests' ) , undefined , undefined , ( ) => this . defaultDebug ( ) ) ) ;
816
816
}
817
817
818
+ const testItems = this . tests . map ( testItem => ( {
819
+ currentLabel : testItem . test . item . label ,
820
+ testItem,
821
+ parent : testItem . test . parent ,
822
+ } ) ) ;
823
+
824
+ const getLabelConflicts = ( tests : typeof testItems ) => {
825
+ const labelCount = new Map < string , number > ( ) ;
826
+ for ( const test of tests ) {
827
+ labelCount . set ( test . currentLabel , ( labelCount . get ( test . currentLabel ) || 0 ) + 1 ) ;
828
+ }
829
+
830
+ return tests . filter ( e => labelCount . get ( e . currentLabel ) ! > 1 ) ;
831
+ } ;
832
+
833
+ let conflicts , hasParent = true ;
834
+ while ( ( conflicts = getLabelConflicts ( testItems ) ) . length && hasParent ) {
835
+ for ( const conflict of conflicts ) {
836
+ if ( conflict . parent ) {
837
+ const parent = this . testService . collection . getNodeById ( conflict . parent ) ;
838
+ conflict . currentLabel = parent ?. item . label + ' > ' + conflict . currentLabel ;
839
+ conflict . parent = parent ?. parent ? parent . parent : null ;
840
+ } else {
841
+ hasParent = false ;
842
+ }
843
+ }
844
+ }
845
+
818
846
const disposable = new DisposableStore ( ) ;
819
- const testSubmenus = this . tests . map ( ( { test , resultItem } ) => {
820
- const actions = this . getTestContextMenuActions ( test , resultItem ) ;
847
+ const testSubmenus = testItems . map ( ( { currentLabel , testItem } ) => {
848
+ const actions = this . getTestContextMenuActions ( testItem . test , testItem . resultItem ) ;
821
849
disposable . add ( actions ) ;
822
- return new SubmenuAction ( test . item . extId , stripIcons ( test . item . label ) , actions . object ) ;
850
+ return new SubmenuAction ( testItem . test . item . extId , stripIcons ( currentLabel ) , actions . object ) ;
823
851
} ) ;
824
852
825
853
return { object : Separator . join ( allActions , testSubmenus ) , dispose : ( ) => disposable . dispose ( ) } ;
0 commit comments