Skip to content

Commit

Permalink
Fix #93538. remove output in webview first before removing a cell
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Mar 27, 2020
1 parent 612b400 commit 4486892
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
Expand Up @@ -342,11 +342,27 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
this.localStore.add(this.notebookViewModel.onDidChangeViewCells((e) => {
if (e.synchronous) {
e.splices.reverse().forEach((diff) => {
// remove output in the webview
for (let i = diff[0]; i < diff[0] + diff[1]; i++) {
const cell = this.list?.element(i);
cell?.cell.outputs.forEach(output => {
this.removeInset(output);
});
}

this.list?.splice(diff[0], diff[1], diff[2]);
});
} else {
DOM.scheduleAtNextAnimationFrame(() => {
e.splices.reverse().forEach((diff) => {
// remove output in the webview
for (let i = diff[0]; i < diff[0] + diff[1]; i++) {
const cell = this.list?.element(i);
cell?.cell.outputs.forEach(output => {
this.removeInset(output);
});
}

this.list?.splice(diff[0], diff[1], diff[2]);
});
});
Expand Down
3 changes: 3 additions & 0 deletions src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
Expand Up @@ -23,6 +23,9 @@ import { NotebookEventDispatcher } from 'vs/workbench/contrib/notebook/browser/v

export class TestCell implements ICell {
uri: URI;
private _onDidChangeContent = new Emitter<void>();
onDidChangeContent: Event<void> = this._onDidChangeContent.event;

private _onDidChangeOutputs = new Emitter<NotebookCellOutputsSplice[]>();
onDidChangeOutputs: Event<NotebookCellOutputsSplice[]> = this._onDidChangeOutputs.event;
private _onDidChangeLanguage = new Emitter<string>();
Expand Down

0 comments on commit 4486892

Please sign in to comment.