@@ -183,6 +183,7 @@ class CellOutputElement extends Disposable {
183
183
const index = this . viewCell . outputsViewModels . indexOf ( this . output ) ;
184
184
185
185
if ( this . viewCell . isOutputCollapsed || ! this . notebookEditor . hasModel ( ) ) {
186
+ this . cellOutputContainer . flagAsStale ( ) ;
186
187
return undefined ;
187
188
}
188
189
@@ -477,6 +478,7 @@ const enum CellOutputUpdateContext {
477
478
478
479
export class CellOutputContainer extends CellContentPart {
479
480
private _outputEntries : OutputEntryViewHandler [ ] = [ ] ;
481
+ private _hasStaleOutputs : boolean = false ;
480
482
481
483
get renderedOutputEntries ( ) {
482
484
return this . _outputEntries ;
@@ -534,6 +536,13 @@ export class CellOutputContainer extends CellContentPart {
534
536
}
535
537
}
536
538
539
+ /**
540
+ * Notify that an output may have been swapped out without the model getting rendered.
541
+ */
542
+ flagAsStale ( ) {
543
+ this . _hasStaleOutputs = true ;
544
+ }
545
+
537
546
private _doRender ( ) {
538
547
if ( this . viewCell . outputsViewModels . length > 0 ) {
539
548
if ( this . viewCell . layoutInfo . outputTotalHeight !== 0 ) {
@@ -569,6 +578,13 @@ export class CellOutputContainer extends CellContentPart {
569
578
}
570
579
571
580
viewUpdateShowOutputs ( initRendering : boolean ) : void {
581
+ if ( this . _hasStaleOutputs ) {
582
+ this . _hasStaleOutputs = false ;
583
+ this . _outputEntries . forEach ( entry => {
584
+ entry . element . rerender ( ) ;
585
+ } ) ;
586
+ }
587
+
572
588
for ( let index = 0 ; index < this . _outputEntries . length ; index ++ ) {
573
589
const viewHandler = this . _outputEntries [ index ] ;
574
590
const outputEntry = viewHandler . element ;
0 commit comments