@@ -46,7 +46,7 @@ const {
4646
4747const { ERR_DEBUGGER_ERROR } = require ( 'internal/errors' ) . codes ;
4848
49- const { validateString } = require ( 'internal/validators' ) ;
49+ const { validateString, validateNumber } = require ( 'internal/validators' ) ;
5050
5151const FS = require ( 'fs' ) ;
5252const Path = require ( 'path' ) ;
@@ -81,7 +81,7 @@ out, o Step out, leaving the current function
8181backtrace, bt Print the current backtrace
8282list Print the source around the current line where execution
8383 is currently paused
84-
84+ setContextLineNumber Set which lines to check for context
8585setBreakpoint, sb Set a breakpoint
8686clearBreakpoint, cb Clear a breakpoint
8787breakpoints List all known breakpoints
@@ -381,6 +381,7 @@ function createRepl(inspector) {
381381let currentBacktrace ;
382382let selectedFrame ;
383383let exitDebugRepl ;
384+ let contextLineNumber = 2 ;
384385
385386function resetOnStart ( ) {
386387knownScripts = { } ;
@@ -685,6 +686,15 @@ function createRepl(inspector) {
685686} ) ;
686687}
687688
689+ function setContextLineNumber ( delta = 2 ) {
690+ if ( ! selectedFrame ) {
691+ throw new ERR_DEBUGGER_ERROR ( 'Requires execution to be paused' ) ;
692+ }
693+ validateNumber ( delta , 'delta' , 1 ) ;
694+ contextLineNumber = delta ;
695+ print ( `The contextLine has been changed to ${ delta } .` ) ;
696+ }
697+
688698function handleBreakpointResolved ( { breakpointId, location } ) {
689699const script = knownScripts [ location . scriptId ] ;
690700const scriptUrl = script && script . url ;
@@ -897,7 +907,7 @@ function createRepl(inspector) {
897907
898908inspector . suspendReplWhile ( ( ) =>
899909PromisePrototypeThen (
900- SafePromiseAllReturnArrayLike ( [ formatWatchers ( true ) , selectedFrame . list ( 2 ) ] ) ,
910+ SafePromiseAllReturnArrayLike ( [ formatWatchers ( true ) , selectedFrame . list ( contextLineNumber ) ] ) ,
901911( { 0 : watcherList , 1 : context } ) => {
902912const breakContext = watcherList ?
903913`${ watcherList } \n${ inspect ( context ) } ` :
@@ -1159,6 +1169,7 @@ function createRepl(inspector) {
11591169} ,
11601170
11611171 list,
1172+ setContextLineNumber,
11621173} ) ;
11631174aliasProperties ( context , SHORTCUTS ) ;
11641175}
0 commit comments