@@ -48,6 +48,7 @@ export class AttachDebugSession extends LoggingDebugSession implements ExprEvalu
4848 private breakpoints = new Map < string , EmmyBreakpoint [ ] > ( ) ;
4949 private loadedScripts = new Map < string , LoadedScript > ( ) ;
5050 private break ?: DMBreak ;
51+ private curFrameId = 0 ;
5152 private handles : Handles < IStackNode > = new Handles < IStackNode > ( ) ;
5253 private evalIdCounter = 0 ;
5354 private evalMap = new Map < number , ( v :DMRespEvaluate ) => void > ( ) ;
@@ -346,7 +347,7 @@ export class AttachDebugSession extends LoggingDebugSession implements ExprEvalu
346347 if ( script ) {
347348 source = new Source ( path . basename ( script . path ) , this . resolvePath ( script . path ) ) ;
348349 }
349- return new StackFrame ( index , root . functionName , source , this . convertDebuggerLineToClient ( root . line ) ) ;
350+ return new StackFrame ( index ++ , root . functionName , source , this . convertDebuggerLineToClient ( root . line ) ) ;
350351 } ) ,
351352 totalFrames : stacks . children . length
352353 } ;
@@ -355,11 +356,12 @@ export class AttachDebugSession extends LoggingDebugSession implements ExprEvalu
355356 }
356357
357358 protected scopesRequest ( response : DebugProtocol . ScopesResponse , args : DebugProtocol . ScopesArguments ) : void {
359+ this . curFrameId = args . frameId ;
358360 const stack = this . break ! . stacks ! . children [ args . frameId ] ;
359361 response . body = {
360362 scopes : [
361363 {
362- name : "Local " ,
364+ name : "Variables " ,
363365 variablesReference : this . handles . create ( stack ) ,
364366 expensive : false
365367 }
@@ -402,8 +404,9 @@ export class AttachDebugSession extends LoggingDebugSession implements ExprEvalu
402404 }
403405
404406 protected evaluateRequest ( response : DebugProtocol . EvaluateResponse , args : DebugProtocol . EvaluateArguments ) : void {
405- const stackId = args . frameId || 0 ;
406- this . eval ( args . expression , stackId ) . then ( v => {
407+ const frameId = args . frameId || 0 ;
408+ this . curFrameId = frameId ;
409+ this . eval ( args . expression , frameId ) . then ( v => {
407410 const ctx = { evaluator : this , handles : this . handles , scriptManager : this } ;
408411 const variable = v . resultNode . children [ 0 ] . toVariable ( ctx ) ;
409412 response . body = {
@@ -414,10 +417,13 @@ export class AttachDebugSession extends LoggingDebugSession implements ExprEvalu
414417 } ) ;
415418 }
416419
417- eval ( expr : string , stack : number ) : Thenable < DMRespEvaluate > {
420+ eval ( expr : string , frameId : number = - 1 ) : Thenable < DMRespEvaluate > {
421+ if ( frameId < 0 ) {
422+ frameId = this . curFrameId ;
423+ }
418424 return new Promise ( ( resolve ) => {
419425 const id = this . evalIdCounter ++ ;
420- const stackId = stack ;
426+ const stackId = frameId ;
421427 const req = new DMReqEvaluate ( this . break ! . L , id , stackId , expr , 2 ) ;
422428 this . evalMap . set ( id , resolve ) ;
423429 this . send ( req ) ;
0 commit comments