Repository navigation
fix(editor): keep notebook cell undo across cell and tab switches - #34952
Conversation
76ad7b8 to
b208913
Compare
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryKeeps notebook cell undo history across cell switches and notebook view remounts.
No actionable issues were found. Tests were not run during this review.
|
Notebook cell models were anonymous and disposed whenever a cell lost focus or the notebook view unmounted on a tab switch, so Undo did nothing after returning to a cell. Give cells that have a stable nbformat id a vscode-userdata model URI, scoped to the view, so Monaco's model service keeps and restores the disposed model's undo stack. Monaco restores only when the text is unchanged and bounds retained history to its closed-file budget. Id-less cells keep anonymous models because their position-based key can move to a different cell, and a duplicate id falls back to an anonymous model instead of colliding.
b208913 to
35643c5
Compare
Problem
A notebook cell's Monaco model was anonymous and was disposed when the cell lost focus or when the notebook view unmounted (for example on a file tab switch). After returning to a cell, Undo did nothing. Regular file tabs keep their undo history.
This PR also folds in #35008 (undo after tab switches), so both cases are handled by one mechanism.
Fix
vscode-userdata:/[fileId, view scope, cell id]). Monaco's model service keeps the undo stack of a disposed model with that scheme and restores it when a model with the same URI is created again. It restores only if the text is unchanged (SHA1 check), so an external reload or Discard while the cell was inactive drops the old history. Retained history counts against Monaco's existing 20 MiB closed-file undo budget, which it shares with closed file tabs, and is evicted in LRU order.vscode-userdatais used rather thanvscode-notebook-cellbecause, in the shipped Monaco 0.55.1 ESM, only the model service checks it. The notebook-cell scheme also enables notebook-specific paths in word highlighting, inline completions and language detection.Cannot add model because it already exists.Testing
New cases in
IpynbCellEditor.external-sync.test.tsx(real Monaco models):pnpm teston the two notebook editor test files passes.ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2passes. The app was not launched for this revision. The change is renderer-only, with no platform, remote or wire impact, and applies the same way to git and folder workspaces.