Skip to content

Commit 600e2b6

Browse files
authored
handle updates while outputs are collapsed (microsoft#204201)
* handle updates while outputs are collapsed * naming, comments
1 parent 446a88c commit 600e2b6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2830,7 +2830,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
28302830

28312831
async updateOutput(cell: CodeCellViewModel, output: IInsetRenderOutput, offset: number): Promise<void> {
28322832
this._insetModifyQueueByOutputId.queue(output.source.model.outputId, async () => {
2833-
if (this._isDisposed || !this._webview) {
2833+
if (this._isDisposed || !this._webview || cell.isOutputCollapsed) {
28342834
return;
28352835
}
28362836

src/vs/workbench/contrib/notebook/browser/view/cellParts/cellOutput.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ class CellOutputElement extends Disposable {
183183
const index = this.viewCell.outputsViewModels.indexOf(this.output);
184184

185185
if (this.viewCell.isOutputCollapsed || !this.notebookEditor.hasModel()) {
186+
this.cellOutputContainer.flagAsStale();
186187
return undefined;
187188
}
188189

@@ -477,6 +478,7 @@ const enum CellOutputUpdateContext {
477478

478479
export class CellOutputContainer extends CellContentPart {
479480
private _outputEntries: OutputEntryViewHandler[] = [];
481+
private _hasStaleOutputs: boolean = false;
480482

481483
get renderedOutputEntries() {
482484
return this._outputEntries;
@@ -534,6 +536,13 @@ export class CellOutputContainer extends CellContentPart {
534536
}
535537
}
536538

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+
537546
private _doRender() {
538547
if (this.viewCell.outputsViewModels.length > 0) {
539548
if (this.viewCell.layoutInfo.outputTotalHeight !== 0) {
@@ -569,6 +578,13 @@ export class CellOutputContainer extends CellContentPart {
569578
}
570579

571580
viewUpdateShowOutputs(initRendering: boolean): void {
581+
if (this._hasStaleOutputs) {
582+
this._hasStaleOutputs = false;
583+
this._outputEntries.forEach(entry => {
584+
entry.element.rerender();
585+
});
586+
}
587+
572588
for (let index = 0; index < this._outputEntries.length; index++) {
573589
const viewHandler = this._outputEntries[index];
574590
const outputEntry = viewHandler.element;

0 commit comments

Comments
 (0)