@@ -81,7 +81,7 @@ out, o Step out, leaving the current function
81
81
backtrace, bt Print the current backtrace
82
82
list Print the source around the current line where execution
83
83
is currently paused
84
-
84
+ setContextLineNumber Set which lines to check for context
85
85
setBreakpoint, sb Set a breakpoint
86
86
clearBreakpoint, cb Clear a breakpoint
87
87
breakpoints List all known breakpoints
@@ -381,6 +381,7 @@ function createRepl(inspector) {
381
381
let currentBacktrace ;
382
382
let selectedFrame ;
383
383
let exitDebugRepl ;
384
+ let contextLineNumber = 2 ;
384
385
385
386
function resetOnStart ( ) {
386
387
knownScripts = { } ;
@@ -685,6 +686,19 @@ function createRepl(inspector) {
685
686
} ) ;
686
687
}
687
688
689
+ function setContextLineNumber ( delta = 2 ) {
690
+ if ( ! selectedFrame ) {
691
+ throw new ERR_DEBUGGER_ERROR ( 'Requires execution to be paused' ) ;
692
+ }
693
+ try {
694
+ contextLineNumber = delta ;
695
+ print ( `The contextLine has been changed to ${ delta } .` ) ;
696
+ } catch ( error ) {
697
+ print ( "You can't setContextLineNumber source code right now" ) ;
698
+ throw error ;
699
+ }
700
+ }
701
+
688
702
function handleBreakpointResolved ( { breakpointId, location } ) {
689
703
const script = knownScripts [ location . scriptId ] ;
690
704
const scriptUrl = script && script . url ;
@@ -897,7 +911,7 @@ function createRepl(inspector) {
897
911
898
912
inspector . suspendReplWhile ( ( ) =>
899
913
PromisePrototypeThen (
900
- SafePromiseAllReturnArrayLike ( [ formatWatchers ( true ) , selectedFrame . list ( 2 ) ] ) ,
914
+ SafePromiseAllReturnArrayLike ( [ formatWatchers ( true ) , selectedFrame . list ( contextLineNumber ) ] ) ,
901
915
( { 0 : watcherList , 1 : context } ) => {
902
916
const breakContext = watcherList ?
903
917
`${ watcherList } \n${ inspect ( context ) } ` :
@@ -1159,6 +1173,7 @@ function createRepl(inspector) {
1159
1173
} ,
1160
1174
1161
1175
list,
1176
+ setContextLineNumber,
1162
1177
} ) ;
1163
1178
aliasProperties ( context , SHORTCUTS ) ;
1164
1179
}
0 commit comments