@@ -20,7 +20,7 @@ import {
20
20
import { injectable , inject } from '@theia/core/shared/inversify' ;
21
21
import * as monaco from '@theia/monaco-editor-core' ;
22
22
import { MenuModelRegistry , CommandRegistry , MAIN_MENU_BAR , Command , Emitter , Mutable , CompoundMenuNodeRole } from '@theia/core/lib/common' ;
23
- import { EDITOR_LINENUMBER_CONTEXT_MENU , EditorManager } from '@theia/editor/lib/browser' ;
23
+ import { EDITOR_CONTEXT_MENU , EDITOR_LINENUMBER_CONTEXT_MENU , EditorManager } from '@theia/editor/lib/browser' ;
24
24
import { DebugSessionManager } from './debug-session-manager' ;
25
25
import { DebugWidget } from './view/debug-widget' ;
26
26
import { FunctionBreakpoint } from './breakpoint/breakpoint-marker' ;
@@ -241,6 +241,11 @@ export namespace DebugCommands {
241
241
id : 'editor.debug.action.showDebugHover' ,
242
242
label : 'Debug: Show Hover'
243
243
} ) ;
244
+ export const JUMP_TO_CURSOR = Command . toDefaultLocalizedCommand ( {
245
+ id : 'editor.debug.action.jumpToCursor' ,
246
+ category : DEBUG_CATEGORY ,
247
+ label : 'Jump to Cursor'
248
+ } ) ;
244
249
245
250
export const RESTART_FRAME = Command . toDefaultLocalizedCommand ( {
246
251
id : 'debug.frame.restart' ,
@@ -376,6 +381,9 @@ export namespace DebugEditorContextCommands {
376
381
export const DISABLE_LOGPOINT = {
377
382
id : 'debug.editor.context.logpoint.disable'
378
383
} ;
384
+ export const JUMP_TO_CURSOR = {
385
+ id : 'debug.editor.context.jumpToCursor'
386
+ } ;
379
387
}
380
388
export namespace DebugBreakpointWidgetCommands {
381
389
export const ACCEPT = {
@@ -613,6 +621,11 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
613
621
DebugCommands . DISABLE_ALL_BREAKPOINTS
614
622
) ;
615
623
624
+ const DEBUG_EDITOR_CONTEXT_MENU_GROUP = [ ...EDITOR_CONTEXT_MENU , '2_debug' ] ;
625
+ registerMenuActions ( DEBUG_EDITOR_CONTEXT_MENU_GROUP ,
626
+ DebugCommands . JUMP_TO_CURSOR
627
+ ) ;
628
+
616
629
registerMenuActions ( DebugEditorModel . CONTEXT_MENU ,
617
630
{ ...DebugEditorContextCommands . ADD_BREAKPOINT , label : nls . localizeByDefault ( 'Add Breakpoint' ) } ,
618
631
{ ...DebugEditorContextCommands . ADD_CONDITIONAL_BREAKPOINT , label : DebugCommands . ADD_CONDITIONAL_BREAKPOINT . label } ,
@@ -624,7 +637,8 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
624
637
{ ...DebugEditorContextCommands . REMOVE_LOGPOINT , label : DebugCommands . REMOVE_LOGPOINT . label } ,
625
638
{ ...DebugEditorContextCommands . EDIT_LOGPOINT , label : DebugCommands . EDIT_LOGPOINT . label } ,
626
639
{ ...DebugEditorContextCommands . ENABLE_LOGPOINT , label : nlsEnableBreakpoint ( 'Logpoint' ) } ,
627
- { ...DebugEditorContextCommands . DISABLE_LOGPOINT , label : nlsDisableBreakpoint ( 'Logpoint' ) }
640
+ { ...DebugEditorContextCommands . DISABLE_LOGPOINT , label : nlsDisableBreakpoint ( 'Logpoint' ) } ,
641
+ { ...DebugEditorContextCommands . JUMP_TO_CURSOR , label : nls . localizeByDefault ( 'Jump to Cursor' ) }
628
642
) ;
629
643
menus . linkSubmenu ( EDITOR_LINENUMBER_CONTEXT_MENU , DebugEditorModel . CONTEXT_MENU , { role : CompoundMenuNodeRole . Group } ) ;
630
644
}
@@ -837,6 +851,20 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
837
851
isEnabled : ( ) => this . editors . canShowHover ( )
838
852
} ) ;
839
853
854
+ registry . registerCommand ( DebugCommands . JUMP_TO_CURSOR , {
855
+ execute : ( ) => {
856
+ const model = this . editors . model ;
857
+ if ( model && this . manager . currentThread ) {
858
+ this . manager . currentThread . jumpToCursor (
859
+ model . editor . getResourceUri ( ) ,
860
+ model . position
861
+ ) ;
862
+ }
863
+ } ,
864
+ isEnabled : ( ) => ! ! this . manager . currentThread && this . manager . currentThread . supportsGoto ,
865
+ isVisible : ( ) => ! ! this . manager . currentThread && this . manager . currentThread . supportsGoto
866
+ } ) ;
867
+
840
868
registry . registerCommand ( DebugCommands . RESTART_FRAME , {
841
869
execute : ( ) => this . selectedFrame && this . selectedFrame . restart ( ) ,
842
870
isEnabled : ( ) => ! ! this . selectedFrame
@@ -936,6 +964,15 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
936
964
isEnabled : position => this . isPosition ( position ) && ! ! this . editors . getLogpointEnabled ( this . asPosition ( position ) ) ,
937
965
isVisible : position => this . isPosition ( position ) && ! ! this . editors . getLogpointEnabled ( this . asPosition ( position ) )
938
966
} ) ;
967
+ registry . registerCommand ( DebugEditorContextCommands . JUMP_TO_CURSOR , {
968
+ execute : position => {
969
+ if ( this . isPosition ( position ) && this . editors . currentUri && this . manager . currentThread ) {
970
+ this . manager . currentThread . jumpToCursor ( this . editors . currentUri , this . asPosition ( position ) ) ;
971
+ }
972
+ } ,
973
+ isEnabled : ( ) => ! ! this . manager . currentThread && this . manager . currentThread . supportsGoto ,
974
+ isVisible : ( ) => ! ! this . manager . currentThread && this . manager . currentThread . supportsGoto
975
+ } ) ;
939
976
940
977
registry . registerCommand ( DebugBreakpointWidgetCommands . ACCEPT , {
941
978
execute : ( ) => this . editors . acceptBreakpoint ( )
0 commit comments