@@ -14,6 +14,8 @@ import { IDebugService, CONTEXT_IN_DEBUG_MODE, CONTEXT_NOT_IN_DEBUG_REPL, CONTEX
1414import { IPanelService } from 'vs/workbench/services/panel/common/panelService' ;
1515import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet' ;
1616import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
17+ import { IEditorService } from 'vs/platform/editor/common/editor' ;
18+ import { openBreakpointSource } from 'vs/workbench/parts/debug/browser/breakpointsView' ;
1719
1820class ToggleBreakpointAction extends EditorAction {
1921 constructor ( ) {
@@ -209,10 +211,73 @@ class ShowDebugHoverAction extends EditorAction {
209211 }
210212}
211213
214+ class GoToBreakpointAction extends EditorAction {
215+ constructor ( private isNext , opts ) {
216+ super ( opts ) ;
217+ }
218+
219+ public run ( accessor : ServicesAccessor , editor : ICodeEditor , args : any ) : void | TPromise < void , any > {
220+ const debugService = accessor . get ( IDebugService ) ;
221+ const editorService = accessor . get ( IEditorService ) ;
222+ const currentUri = editor . getModel ( ) . uri ;
223+ const currentLine = editor . getPosition ( ) . lineNumber ;
224+ //Breakpoints returned from `getBreakpoints` are already sorted.
225+ const allEnabledBreakpoints = debugService . getModel ( ) . getBreakpoints ( { enabledOnly : true } ) ;
226+
227+ //Try to find breakpoint in current file
228+ let moveBreakpoint =
229+ this . isNext
230+ ? allEnabledBreakpoints . filter ( bp => bp . uri . toString ( ) === currentUri . toString ( ) && bp . lineNumber > currentLine ) [ 0 ]
231+ : allEnabledBreakpoints . filter ( bp => bp . uri . toString ( ) === currentUri . toString ( ) && bp . lineNumber < currentLine ) [ 0 ] ;
232+
233+ //Try to find breakpoints in following files
234+ if ( ! moveBreakpoint ) {
235+ moveBreakpoint =
236+ this . isNext
237+ ? allEnabledBreakpoints . filter ( bp => bp . uri . toString ( ) > currentUri . toString ( ) ) [ 0 ]
238+ : allEnabledBreakpoints . filter ( bp => bp . uri . toString ( ) < currentUri . toString ( ) ) [ 0 ] ;
239+ }
240+
241+ //Move to first possible breakpoint
242+ if ( ! moveBreakpoint ) {
243+ moveBreakpoint = allEnabledBreakpoints [ 0 ] ;
244+ }
245+
246+ if ( moveBreakpoint ) {
247+ openBreakpointSource ( moveBreakpoint , false , true , debugService , editorService ) ;
248+ }
249+ return TPromise . as ( null ) ;
250+ }
251+ }
252+
253+ class GoToNextBreakpointAction extends GoToBreakpointAction {
254+ constructor ( ) {
255+ super ( true , {
256+ id : 'editor.debug.action.goToNextBreakpoint' ,
257+ label : nls . localize ( 'goToNextBreakpoint' , "Debug: Go To Next Breakpoint" ) ,
258+ alias : 'Debug: Go To Next Breakpoint' ,
259+ precondition : null
260+ } ) ;
261+ }
262+ }
263+
264+ class GoToPreviousBreakpointAction extends GoToBreakpointAction {
265+ constructor ( ) {
266+ super ( false , {
267+ id : 'editor.debug.action.goToPreviousBreakpoint' ,
268+ label : nls . localize ( 'goToPreviousBreakpoint' , "Debug: Go To Previous Breakpoint" ) ,
269+ alias : 'Debug: Go To Previous Breakpoint' ,
270+ precondition : null
271+ } ) ;
272+ }
273+ }
274+
212275registerEditorAction ( ToggleBreakpointAction ) ;
213276registerEditorAction ( ConditionalBreakpointAction ) ;
214277registerEditorAction ( LogPointAction ) ;
215278registerEditorAction ( RunToCursorAction ) ;
216279registerEditorAction ( SelectionToReplAction ) ;
217280registerEditorAction ( SelectionToWatchExpressionsAction ) ;
218281registerEditorAction ( ShowDebugHoverAction ) ;
282+ registerEditorAction ( GoToNextBreakpointAction ) ;
283+ registerEditorAction ( GoToPreviousBreakpointAction ) ;
0 commit comments