@@ -9,14 +9,17 @@ import { Range } from 'vs/editor/common/core/range';
99import { EditorContextKeys } from 'vs/editor/common/editorContextKeys' ;
1010import { ServicesAccessor , registerEditorAction , EditorAction , IActionOptions } from 'vs/editor/browser/editorExtensions' ;
1111import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
12- import { IDebugService , CONTEXT_IN_DEBUG_MODE , CONTEXT_DEBUG_STATE , State , VIEWLET_ID , IDebugEditorContribution , EDITOR_CONTRIBUTION_ID , BreakpointWidgetContext , IBreakpoint , BREAKPOINT_EDITOR_CONTRIBUTION_ID , IBreakpointEditorContribution , REPL_VIEW_ID } from 'vs/workbench/contrib/debug/common/debug' ;
12+ import { IDebugService , CONTEXT_IN_DEBUG_MODE , CONTEXT_DEBUG_STATE , State , VIEWLET_ID , IDebugEditorContribution , EDITOR_CONTRIBUTION_ID , BreakpointWidgetContext , IBreakpoint , BREAKPOINT_EDITOR_CONTRIBUTION_ID , IBreakpointEditorContribution , REPL_VIEW_ID , CONTEXT_STEP_INTO_TARGETS_SUPPORTED } from 'vs/workbench/contrib/debug/common/debug' ;
1313import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet' ;
1414import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
1515import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
1616import { openBreakpointSource } from 'vs/workbench/contrib/debug/browser/breakpointsView' ;
1717import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry' ;
1818import { PanelFocusContext } from 'vs/workbench/common/panel' ;
1919import { IViewsService } from 'vs/workbench/common/views' ;
20+ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView' ;
21+ import { Action } from 'vs/base/common/actions' ;
22+ import { getDomNodePagePosition } from 'vs/base/browser/dom' ;
2023
2124export const TOGGLE_BREAKPOINT_ID = 'editor.debug.action.toggleBreakpoint' ;
2225class ToggleBreakpointAction extends EditorAction {
@@ -241,6 +244,48 @@ class ShowDebugHoverAction extends EditorAction {
241244 }
242245}
243246
247+ class StepIntoTargetsAction extends EditorAction {
248+
249+ public static readonly ID = 'editor.debug.action.stepIntoTargets' ;
250+ public static readonly LABEL = nls . localize ( 'stepIntoTargets' , "Step Into Targets..." ) ;
251+
252+ constructor ( ) {
253+ super ( {
254+ id : StepIntoTargetsAction . ID ,
255+ label : StepIntoTargetsAction . LABEL ,
256+ alias : 'Debug: Step Into Targets...' ,
257+ precondition : ContextKeyExpr . and ( CONTEXT_STEP_INTO_TARGETS_SUPPORTED , CONTEXT_IN_DEBUG_MODE , CONTEXT_DEBUG_STATE . isEqualTo ( 'stopped' ) , EditorContextKeys . editorTextFocus ) ,
258+ contextMenuOpts : {
259+ group : 'debug' ,
260+ order : 1.5
261+ }
262+ } ) ;
263+ }
264+
265+ async run ( accessor : ServicesAccessor , editor : ICodeEditor ) : Promise < void > {
266+ const debugService = accessor . get ( IDebugService ) ;
267+ const contextMenuService = accessor . get ( IContextMenuService ) ;
268+ const session = debugService . getViewModel ( ) . focusedSession ;
269+ const frame = debugService . getViewModel ( ) . focusedStackFrame ;
270+
271+ if ( session && frame && editor . hasModel ( ) ) {
272+ const targets = await session . stepInTargets ( frame . frameId ) ;
273+ const position = editor . getPosition ( ) ;
274+ const cursorCoords = editor . getScrolledVisiblePosition ( position ) ;
275+ const editorCoords = getDomNodePagePosition ( editor . getDomNode ( ) ) ;
276+ const x = editorCoords . left + cursorCoords . left ;
277+ const y = editorCoords . top + cursorCoords . top + cursorCoords . height ;
278+
279+ contextMenuService . showContextMenu ( {
280+ getAnchor : ( ) => ( { x, y } ) ,
281+ getActions : ( ) => {
282+ return targets . map ( t => new Action ( `stepIntoTarget:${ t . id } ` , t . label , undefined , true , ( ) => session . stepIn ( frame . thread . threadId , t . id ) ) ) ;
283+ }
284+ } ) ;
285+ }
286+ }
287+ }
288+
244289class GoToBreakpointAction extends EditorAction {
245290 constructor ( private isNext : boolean , opts : IActionOptions ) {
246291 super ( opts ) ;
@@ -307,6 +352,7 @@ registerEditorAction(ToggleBreakpointAction);
307352registerEditorAction ( ConditionalBreakpointAction ) ;
308353registerEditorAction ( LogPointAction ) ;
309354registerEditorAction ( RunToCursorAction ) ;
355+ registerEditorAction ( StepIntoTargetsAction ) ;
310356registerEditorAction ( SelectionToReplAction ) ;
311357registerEditorAction ( SelectionToWatchExpressionsAction ) ;
312358registerEditorAction ( ShowDebugHoverAction ) ;
0 commit comments