@@ -42,7 +42,10 @@ import { existsSync, mkdirSync, rmSync, writeFileSync } from 'fs';
4242import { dirname , join } from 'path' ;
4343import * as vscode from 'vscode' ;
4444
45- import { ICurrentCell } from './idl-notebook-controller.interface' ;
45+ import {
46+ ICurrentCell ,
47+ IEndCellExecutionActions ,
48+ } from './idl-notebook-controller.interface' ;
4649import { ProcessIDLNotebookEmbeddedItems } from './process-idl-notebook-embedded-items' ;
4750
4851/**
@@ -157,7 +160,7 @@ export class IDLNotebookController {
157160 content : [ `Stopped because: "${ reason } "` , stack ] ,
158161 } ) ;
159162
160- await this . _endCellExecution ( false ) ;
163+ await this . _endCellExecution ( false , { decorateStack : true } ) ;
161164 } ) ;
162165
163166 // listen for debug output
@@ -322,7 +325,10 @@ export class IDLNotebookController {
322325 * We also do post-processing and, if we succeeded, we try to retrieve any
323326 * graphics.
324327 */
325- private async _endCellExecution ( success : boolean , postExecute = true ) {
328+ private async _endCellExecution (
329+ success : boolean ,
330+ actions : Partial < IEndCellExecutionActions > = { }
331+ ) {
326332 /**
327333 * Get current cell
328334 */
@@ -348,6 +354,28 @@ export class IDLNotebookController {
348354 this . _runtime . once ( IDL_EVENT_LOOKUP . END , onDidCloseWhileBusy ) ;
349355 this . _runtime . once ( IDL_EVENT_LOOKUP . CRASHED , onDidCloseWhileBusy ) ;
350356
357+ // check if we need to decorate our call stack
358+ if ( this . isStarted ( ) && actions . decorateStack ) {
359+ // get the current scope
360+ const stack = ( await this . _runtime . getCurrentStack ( ) ) . reverse ( ) ;
361+
362+ // get the fsPath for the current cell
363+ const fsPath = IDLFileHelper . notebookCellUriToFSPath (
364+ cell . cell . document . uri
365+ ) ;
366+
367+ /** Check if any of our scope items are in this notebook cell */
368+ const ourFile = stack . filter ( ( item ) => item . file === fsPath ) ;
369+
370+ // see if we have a location we stopped on
371+ if ( ourFile . length > 0 ) {
372+ IDL_DECORATIONS_MANAGER . addStackTraceDecorations (
373+ cell . cell . document . uri ,
374+ ourFile . map ( ( item ) => item . line - 1 ) // in notebooks, we need zero-based instead of one
375+ ) ;
376+ }
377+ }
378+
351379 /**
352380 * Wrap in try/catch so we don't have to worry about unhandled promise exceptions
353381 */
@@ -364,7 +392,7 @@ export class IDLNotebookController {
364392 *
365393 * Only run this if launched. If not launched we hang forever, for some reason
366394 */
367- if ( success && postExecute && this . isStarted ( ) ) {
395+ if ( success && actions . postExecute && this . isStarted ( ) ) {
368396 await this . postCellExecution ( success , cell ) ;
369397 }
370398 }
@@ -380,25 +408,6 @@ export class IDLNotebookController {
380408
381409 // always return from current scope
382410 if ( this . isStarted ( ) ) {
383- // get the current scope
384- const stack = ( await this . _runtime . getCurrentStack ( ) ) . reverse ( ) ;
385-
386- // get the fsPath for the current cell
387- const fsPath = IDLFileHelper . notebookCellUriToFSPath (
388- cell . cell . document . uri
389- ) ;
390-
391- /** Check if any of our scope items are in this notebook cell */
392- const ourFile = stack . filter ( ( item ) => item . file === fsPath ) ;
393-
394- // see if we have a location we stopped on
395- if ( ourFile . length > 0 ) {
396- IDL_DECORATIONS_MANAGER . addStackTraceDecorations (
397- cell . cell . document . uri ,
398- ourFile . map ( ( item ) => item . line - 1 ) // in notebooks, we need zero-based instead of one
399- ) ;
400- }
401-
402411 /**
403412 * Commands to run after executing a cell
404413 *
@@ -675,7 +684,7 @@ export class IDLNotebookController {
675684 ) ;
676685
677686 // make sure cells are done executing
678- this . _endCellExecution ( false , false ) ;
687+ this . _endCellExecution ( false , { postExecute : false } ) ;
679688
680689 // return a prom
681690 return launchPromise ;
0 commit comments