Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
deletedCells.forEach(cell => {
this._handleToViewCellMapping.delete(cell.handle);
// dispose the cell to release ref to the cell text document
cell.dispose();
this._localStore.delete(cell);
});

diff[2].forEach(cell => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,32 @@ suite('NotebookViewModel', () => {
);
});

test('deleted cells are removed from the disposable store', async function () {
const getDisposeCallCount = await withTestNotebook(
[
['var a = 1;', 'javascript', CellKind.Code, [], {}],
['var b = 2;', 'javascript', CellKind.Code, [], {}]
],
(editor, viewModel) => {
const cell = insertCellAtIndex(viewModel, 1, 'var c = 3', 'javascript', CellKind.Code, {}, [], true, true);
const originalDispose = cell.dispose.bind(cell);
let disposeCallCount = 0;
cell.dispose = () => {
disposeCallCount++;
originalDispose();
};

runDeleteAction(editor, cell);
assert.strictEqual(disposeCallCount, 1);
cell.model.dispose();

return () => disposeCallCount;
}
);

assert.strictEqual(getDisposeCallCount(), 1);
});

test('index', async function () {
await withTestNotebook(
[
Expand Down
Loading