@@ -31,7 +31,7 @@ import 'vs/css!./media/testing';
31
31
import { MarkdownRenderer } from 'vs/editor/browser/widget/markdownRenderer/browser/markdownRenderer' ;
32
32
import { localize } from 'vs/nls' ;
33
33
import { DropdownWithPrimaryActionViewItem } from 'vs/platform/actions/browser/dropdownWithPrimaryActionViewItem' ;
34
- import { MenuEntryActionViewItem , createActionViewItem , createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem' ;
34
+ import { MenuEntryActionViewItem , createActionViewItem , createAndFillInActionBarActions , createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem' ;
35
35
import { IMenuService , MenuId , MenuItemAction } from 'vs/platform/actions/common/actions' ;
36
36
import { ICommandService } from 'vs/platform/commands/common/commands' ;
37
37
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
@@ -117,6 +117,7 @@ export class TestingExplorerView extends ViewPane {
117
117
@IHoverService hoverService : IHoverService ,
118
118
@ITestProfileService private readonly testProfileService : ITestProfileService ,
119
119
@ICommandService private readonly commandService : ICommandService ,
120
+ @IMenuService private readonly menuService : IMenuService ,
120
121
) {
121
122
super ( options , keybindingService , contextMenuService , configurationService , contextKeyService , viewDescriptorService , instantiationService , openerService , themeService , telemetryService , hoverService ) ;
122
123
@@ -351,10 +352,29 @@ export class TestingExplorerView extends ViewPane {
351
352
}
352
353
}
353
354
354
- // If there's only one group, don't add a heading for it in the dropdown.
355
- if ( participatingGroups === 1 ) {
356
- profileActions . shift ( ) ;
355
+ const menuActions : IAction [ ] = [ ] ;
356
+ const contextKeys : [ string , unknown ] [ ] = [ ] ;
357
+ // allow extension author to define context for when to show the test menu actions for run or debug menus
358
+ if ( group === TestRunProfileBitset . Run ) {
359
+ contextKeys . push ( [ 'testing.profile.context.group' , 'run' ] ) ;
360
+ }
361
+ if ( group === TestRunProfileBitset . Debug ) {
362
+ contextKeys . push ( [ 'testing.profile.context.group' , 'debug' ] ) ;
363
+ }
364
+ if ( group === TestRunProfileBitset . Coverage ) {
365
+ contextKeys . push ( [ 'testing.profile.context.group' , 'coverage' ] ) ;
357
366
}
367
+ const key = this . contextKeyService . createOverlay ( contextKeys ) ;
368
+ const menu = this . menuService . createMenu ( MenuId . TestProfilesContext , key ) ;
369
+
370
+ // fill if there are any actions
371
+ try {
372
+ createAndFillInContextMenuActions ( menu , undefined , menuActions ) ;
373
+ } finally {
374
+ menu . dispose ( ) ;
375
+ }
376
+
377
+
358
378
359
379
const postActions : IAction [ ] = [ ] ;
360
380
if ( profileActions . length > 1 ) {
@@ -377,7 +397,10 @@ export class TestingExplorerView extends ViewPane {
377
397
) ) ;
378
398
}
379
399
380
- return Separator . join ( profileActions , postActions ) ;
400
+ // show menu actions if there are any otherwise don't
401
+ return menuActions . length > 0
402
+ ? Separator . join ( profileActions , menuActions , postActions )
403
+ : Separator . join ( profileActions , postActions ) ;
381
404
}
382
405
383
406
/**
0 commit comments