@@ -24,12 +24,15 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
2424import { registerColor , contrastBorder , widgetShadow } from 'vs/platform/theme/common/colorRegistry' ;
2525import { localize } from 'vs/nls' ;
2626import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
27- import { IContextViewService } from 'vs/platform/contextview/browser/contextView' ;
27+ import { IContextViewService , IContextMenuService } from 'vs/platform/contextview/browser/contextView' ;
2828import { INotificationService } from 'vs/platform/notification/common/notification' ;
2929import { RunOnceScheduler } from 'vs/base/common/async' ;
3030import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
3131import { IDisposable } from 'vs/base/common/lifecycle' ;
3232import { isExtensionHostDebugging } from 'vs/workbench/contrib/debug/common/debugUtils' ;
33+ import { fillInActionBarActions , MenuItemActionItem } from 'vs/platform/actions/browser/menuItemActionItem' ;
34+ import { IMenu , IMenuService , MenuId , MenuItemAction } from 'vs/platform/actions/common/actions' ;
35+ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
3336
3437const DEBUG_TOOLBAR_POSITION_KEY = 'debug.actionswidgetposition' ;
3538const DEBUG_TOOLBAR_Y_KEY = 'debug.actionswidgety' ;
@@ -51,8 +54,9 @@ export class DebugToolbar extends Themable implements IWorkbenchContribution {
5154 private dragArea : HTMLElement ;
5255 private actionBar : ActionBar ;
5356 private allActions : AbstractDebugAction [ ] = [ ] ;
54- private activeActions : AbstractDebugAction [ ] ;
57+ private activeActions : IAction [ ] ;
5558 private updateScheduler : RunOnceScheduler ;
59+ private debugToolbarMenu : IMenu ;
5660
5761 private isVisible : boolean ;
5862 private isBuilt : boolean ;
@@ -67,7 +71,10 @@ export class DebugToolbar extends Themable implements IWorkbenchContribution {
6771 @IThemeService themeService : IThemeService ,
6872 @IKeybindingService private readonly keybindingService : IKeybindingService ,
6973 @IContextViewService contextViewService : IContextViewService ,
70- @IInstantiationService private readonly instantiationService : IInstantiationService
74+ @IInstantiationService private readonly instantiationService : IInstantiationService ,
75+ @IMenuService menuService : IMenuService ,
76+ @IContextMenuService contextMenuService : IContextMenuService ,
77+ @IContextKeyService contextKeyService : IContextKeyService
7178 ) {
7279 super ( themeService ) ;
7380
@@ -77,6 +84,8 @@ export class DebugToolbar extends Themable implements IWorkbenchContribution {
7784 this . dragArea = dom . append ( this . $el , dom . $ ( 'div.drag-area' ) ) ;
7885
7986 const actionBarContainer = dom . append ( this . $el , dom . $ ( 'div.action-bar-container' ) ) ;
87+ this . debugToolbarMenu = menuService . createMenu ( MenuId . DebugToolbar , contextKeyService ) ;
88+ this . toDispose . push ( this . debugToolbarMenu ) ;
8089
8190 this . activeActions = [ ] ;
8291 this . actionBar = this . _register ( new ActionBar ( actionBarContainer , {
@@ -85,6 +94,9 @@ export class DebugToolbar extends Themable implements IWorkbenchContribution {
8594 if ( action . id === FocusSessionAction . ID ) {
8695 return new FocusSessionActionItem ( action , this . debugService , this . themeService , contextViewService ) ;
8796 }
97+ if ( action instanceof MenuItemAction ) {
98+ return new MenuItemActionItem ( action , this . keybindingService , this . notificationService , contextMenuService ) ;
99+ }
88100
89101 return null ;
90102 }
@@ -97,7 +109,7 @@ export class DebugToolbar extends Themable implements IWorkbenchContribution {
97109 return this . hide ( ) ;
98110 }
99111
100- const actions = DebugToolbar . getActions ( this . allActions , this . toDispose , this . debugService , this . keybindingService , this . instantiationService ) ;
112+ const actions = DebugToolbar . getActions ( this . debugToolbarMenu , this . allActions , this . toDispose , this . debugService , this . keybindingService , this . instantiationService ) ;
101113 if ( ! arrays . equals ( actions , this . activeActions , ( first , second ) => first . id === second . id ) ) {
102114 this . actionBar . clear ( ) ;
103115 this . actionBar . push ( actions , { icon : true , label : false } ) ;
@@ -252,7 +264,7 @@ export class DebugToolbar extends Themable implements IWorkbenchContribution {
252264 dom . hide ( this . $el ) ;
253265 }
254266
255- public static getActions ( allActions : AbstractDebugAction [ ] , toDispose : IDisposable [ ] , debugService : IDebugService , keybindingService : IKeybindingService , instantiationService : IInstantiationService ) : AbstractDebugAction [ ] {
267+ public static getActions ( menu : IMenu , allActions : AbstractDebugAction [ ] , toDispose : IDisposable [ ] , debugService : IDebugService , keybindingService : IKeybindingService , instantiationService : IInstantiationService ) : IAction [ ] {
256268 if ( allActions . length === 0 ) {
257269 allActions . push ( new ContinueAction ( ContinueAction . ID , ContinueAction . LABEL , debugService , keybindingService ) ) ;
258270 allActions . push ( new PauseAction ( PauseAction . ID , PauseAction . LABEL , debugService , keybindingService ) ) ;
@@ -264,15 +276,14 @@ export class DebugToolbar extends Themable implements IWorkbenchContribution {
264276 allActions . push ( instantiationService . createInstance ( RestartAction , RestartAction . ID , RestartAction . LABEL ) ) ;
265277 allActions . push ( new StepBackAction ( StepBackAction . ID , StepBackAction . LABEL , debugService , keybindingService ) ) ;
266278 allActions . push ( new ReverseContinueAction ( ReverseContinueAction . ID , ReverseContinueAction . LABEL , debugService , keybindingService ) ) ;
267- allActions . push ( instantiationService . createInstance ( FocusSessionAction , FocusSessionAction . ID , FocusSessionAction . LABEL ) ) ;
268279 allActions . forEach ( a => toDispose . push ( a ) ) ;
269280 }
270281
271282 const state = debugService . state ;
272283 const session = debugService . getViewModel ( ) . focusedSession ;
273284 const attached = session && session . configuration . request === 'attach' && ! isExtensionHostDebugging ( session . configuration ) ;
274285
275- return allActions . filter ( a => {
286+ const actions : IAction [ ] = allActions . filter ( a => {
276287 if ( a . id === ContinueAction . ID ) {
277288 return state !== State . Running ;
278289 }
@@ -291,12 +302,18 @@ export class DebugToolbar extends Themable implements IWorkbenchContribution {
291302 if ( a . id === StopAction . ID ) {
292303 return ! attached ;
293304 }
294- if ( a . id === FocusSessionAction . ID ) {
295- return debugService . getViewModel ( ) . isMultiSessionView ( ) ;
296- }
297305
298306 return true ;
299307 } ) . sort ( ( first , second ) => first . weight - second . weight ) ;
308+
309+ const primary : IAction [ ] = [ ] ;
310+ fillInActionBarActions ( menu , undefined , { primary, secondary : [ ] } ) ;
311+ actions . push ( ...primary ) ;
312+ if ( debugService . getViewModel ( ) . isMultiSessionView ( ) ) {
313+ actions . push ( instantiationService . createInstance ( FocusSessionAction , FocusSessionAction . ID , FocusSessionAction . LABEL ) ) ;
314+ }
315+
316+ return actions ;
300317 }
301318
302319 public dispose ( ) : void {
0 commit comments