@@ -316,18 +316,17 @@ export class StackFrame implements IStackFrame {
316316 return ( from > 0 ? '...' : '' ) + this . source . uri . path . substr ( from ) ;
317317 }
318318
319- getMostSpecificScopes ( range : IRange ) : Promise < IScope [ ] > {
320- return this . getScopes ( ) . then ( scopes => {
321- scopes = scopes . filter ( s => ! s . expensive ) ;
322- const haveRangeInfo = scopes . some ( s => ! ! s . range ) ;
323- if ( ! haveRangeInfo ) {
324- return scopes ;
325- }
319+ async getMostSpecificScopes ( range : IRange ) : Promise < IScope [ ] > {
320+ const scopes = await this . getScopes ( ) ;
321+ const nonExpensiveScopes = scopes . filter ( s => ! s . expensive ) ;
322+ const haveRangeInfo = nonExpensiveScopes . some ( s => ! ! s . range ) ;
323+ if ( ! haveRangeInfo ) {
324+ return nonExpensiveScopes ;
325+ }
326326
327- const scopesContainingRange = scopes . filter ( scope => scope . range && Range . containsRange ( scope . range , range ) )
328- . sort ( ( first , second ) => ( first . range ! . endLineNumber - first . range ! . startLineNumber ) - ( second . range ! . endLineNumber - second . range ! . startLineNumber ) ) ;
329- return scopesContainingRange . length ? scopesContainingRange : scopes ;
330- } ) ;
327+ const scopesContainingRange = nonExpensiveScopes . filter ( scope => scope . range && Range . containsRange ( scope . range , range ) )
328+ . sort ( ( first , second ) => ( first . range ! . endLineNumber - first . range ! . startLineNumber ) - ( second . range ! . endLineNumber - second . range ! . startLineNumber ) ) ;
329+ return scopesContainingRange . length ? scopesContainingRange : nonExpensiveScopes ;
331330 }
332331
333332 restart ( ) : Promise < void > {
@@ -404,23 +403,21 @@ export class Thread implements IThread {
404403 * Only fetches the first stack frame for performance reasons. Calling this method consecutive times
405404 * gets the remainder of the call stack.
406405 */
407- fetchCallStack ( levels = 20 ) : Promise < void > {
408- if ( ! this . stopped ) {
409- return Promise . resolve ( undefined ) ;
410- }
411-
412- const start = this . callStack . length ;
413- return this . getCallStackImpl ( start , levels ) . then ( callStack => {
406+ async fetchCallStack ( levels = 20 ) : Promise < void > {
407+ if ( this . stopped ) {
408+ const start = this . callStack . length ;
409+ const callStack = await this . getCallStackImpl ( start , levels ) ;
414410 if ( start < this . callStack . length ) {
415411 // Set the stack frames for exact position we requested. To make sure no concurrent requests create duplicate stack frames #30660
416412 this . callStack . splice ( start , this . callStack . length - start ) ;
417413 }
418414 this . callStack = this . callStack . concat ( callStack || [ ] ) ;
419- } ) ;
415+ }
420416 }
421417
422- private getCallStackImpl ( startFrame : number , levels : number ) : Promise < IStackFrame [ ] > {
423- return this . session . stackTrace ( this . threadId , startFrame , levels ) . then ( response => {
418+ private async getCallStackImpl ( startFrame : number , levels : number ) : Promise < IStackFrame [ ] > {
419+ try {
420+ const response = await this . session . stackTrace ( this . threadId , startFrame , levels ) ;
424421 if ( ! response || ! response . body ) {
425422 return [ ] ;
426423 }
@@ -439,13 +436,13 @@ export class Thread implements IThread {
439436 rsf . endColumn || rsf . column
440437 ) , startFrame + index ) ;
441438 } ) ;
442- } , ( err : Error ) => {
439+ } catch ( err ) {
443440 if ( this . stoppedDetails ) {
444441 this . stoppedDetails . framesErrorMessage = err . message ;
445442 }
446443
447444 return [ ] ;
448- } ) ;
445+ }
449446 }
450447
451448 /**
0 commit comments