@@ -247,6 +247,7 @@ export class VSCodeNotebookController implements Disposable, IVSCodeNotebookCont
247
247
) ;
248
248
}
249
249
private readonly pendingOutuptsOfNotebooks = new WeakSet < NotebookDocument > ( ) ;
250
+ private readonly restoredConnections = new WeakSet < NotebookDocument > ( ) ;
250
251
public async restoreOutput ( notebook : NotebookDocument ) {
251
252
console . error ( 'Done' ) ;
252
253
const kernel = await this . connectToKernel ( notebook , new DisplayOptions ( true ) ) ;
@@ -270,6 +271,10 @@ export class VSCodeNotebookController implements Disposable, IVSCodeNotebookCont
270
271
console . error ( 'Done' , kernel . uri , kernelExecution . pendingCells . length ) ;
271
272
}
272
273
public async restoreConnection ( notebook : NotebookDocument ) {
274
+ if ( this . restoredConnections . has ( notebook ) ) {
275
+ return ;
276
+ }
277
+ this . restoredConnections . add ( notebook ) ;
273
278
console . error ( 'Done' ) ;
274
279
const kernel = await this . connectToKernel ( notebook , new DisplayOptions ( true ) ) ;
275
280
const kernelExecution = this . kernelProvider . getKernelExecution ( kernel ) ;
@@ -309,13 +314,20 @@ export class VSCodeNotebookController implements Disposable, IVSCodeNotebookCont
309
314
lastExecutionInfo &&
310
315
typeof lastExecutionInfo . index === 'number'
311
316
) {
317
+ let resumed = false ;
318
+ kernel . session . kernel . statusChanged . connect ( ( _ , status ) => {
319
+ console . log ( status ) ;
320
+ } ) ;
312
321
kernel . session . kernel . anyMessage . connect ( ( _ , msg ) => {
322
+ if ( msg . direction === 'send' || resumed ) {
323
+ return ;
324
+ }
313
325
if (
314
- msg . direction === 'recv' &&
315
326
msg . msg . parent_header &&
316
327
'msg_id' in msg . msg . parent_header &&
317
328
msg . msg . parent_header . msg_id === lastExecutionInfo . msg_id
318
329
) {
330
+ resumed = true ;
319
331
kernelExecution
320
332
. resumeCellExecution ( notebook . cellAt ( lastExecutionInfo . index ) , lastExecutionInfo . msg_id )
321
333
. catch ( noop ) ;
0 commit comments