Repository navigation
Remove deleted cells from the NotebookDocuments cell map - #1886
Merged
Dirk Bäumer (dbaeumer) merged 1 commit intoOct 14, 2026
Merged
Dirk Bäumer (dbaeumer) merged 1 commit into
Dirk Bäumer (dbaeumer) merged 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix preserves event behavior and includes regression coverage for the reported stale mapping.
0 open findings
What changed in this PR
Fixes stale notebook-cell mappings after cell deletion.
Changes:
- Removes closed cells from the internal cell map before refreshing it.
- Adds regression coverage for removed-cell lookup and change events.
| File | Description |
|---|---|
server/src/common/notebook.ts |
Deletes stale cell-map entries during notebook changes. |
server/src/node/test/notebookdocuments.test.ts |
Verifies deleted cells are no longer resolvable. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Dirk Bäumer (dbaeumer)
enabled auto-merge (squash)
October 14, 2026 14:06
Dirk Bäumer (dbaeumer)
approved these changes
Oct 14, 2026
Logan Ramos (lramos15)
approved these changes
Oct 14, 2026
roblourens
approved these changes
Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a
notebookDocument/didChangedeletes a cell (structure.didClose),NotebookDocumentssplices the cell out of the notebook and closes its text document. It never removes the cell from its internal cell map, though.updateCellMaponly re-adds the cells that are left. So after deletingcell2from a notebook with[cell1, cell2]:getNotebookCell(cell2)still returns the cell, andfindNotebookDocumentForCell(cell2)still returns the notebook, even thoughcellTextDocuments.get(cell2)isundefined. The stale entry also survivesnotebookDocument/didClose, because the close handler only clears the cells still in the notebook. Each deleted cell therefore keeps its closed notebook reachable.undefined.The fix collects the
removedcells and then drops their map entries before the map is refreshed for the remaining cells, socells.removedin the change event still reports them. The deletion happens after the cell text documents are closed, sofindNotebookDocumentForCellstill works insidecellTextDocuments.onDidCloselisteners. A cell that is closed and re-inserted in the same change is added back byupdateCellMap.npm run compile:serverandcd server && npm test. 15 passing. The new test fails on main withgetNotebookCell(cell2)returning the deleted cell.cd server && npm run lintis clean.