Fix folded markdown cells showing preview on notebook reopen #282380
+19
−0
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.
Description
Folded markdown cells in notebooks display their preview content on reopen, causing visual overlap. This occurs because cells render before folding state is restored—previews are created when
getHiddenRanges()returns empty, then persist when folding is applied.Changes
Two-part fix in
markupCell.ts:Trigger view update on folding state change - When
foldingStateChangedfires (including during state restoration), callviewUpdate()to re-evaluate preview visibility with current hidden rangesCheck hidden ranges before creating preview - In
viewUpdatePreview(), check if cell is in a folded region using populatedgetHiddenRanges(). If hidden, callhideMarkupPreviews()instead ofcreateMarkupPreview()This retroactively hides previews created during initialization once hidden ranges are available.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.