text: remeasure list items when a document is replaced with an equal block count - #2946
Merged
huacnlee merged 2 commits intoSep 4, 2026
Merged
Conversation
Drive a real frame in a windowed test so the list actually measures, then replace the document with one of the same block count and assert the scroll extent grows to match the taller content. Verified by disabling both `invalidate_measured_heights` call sites: the extent reports 1546px instead of 18888px -- about 8% of the true height, which is what seals the wheel clamp. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DJzGY5rMeCxE2r5L6MFzAS
huacnlee
enabled auto-merge (squash)
September 4, 2026 11:46
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.
Document::render_rootonly callsListState::resetwhen the block countchanges. The full-measure pass enabled by
measure_allis a one-shot latch thatonly
reset,remeasure_items, or a width change re-arms. So replacing adocument with one that happens to have the same number of blocks leaves every
cached height belonging to the previous document.
The list summary height stays wrong, and since the wheel clamps against that
summary, the blocks past the false bottom can never scroll into view to be
re-measured. The clamp seals itself.
Reproduction (deterministic)
max_off≈ 3 024 px.max_offis now ≈ 3 503 px instead of the true ≈ 21 314 px. Wheel-scrollingstops at 16 % of the document. Resizing the window "fixes" it, because a
width change re-arms the latch — which is why this is hard to notice
interactively.
Fix
Call
remeasure_items(0..count)at the two placesparsed_contentis replaced(sync and async full-parse paths).
remeasure_itemsre-arms the latch and marksitems unmeasured while keeping the old sizes as hints, so the scrollbar does not
collapse for a frame.
Placement matters: hooking
increment_updateinstead races on the async path —a prepaint can land between the invalidation and the arrival of the new blocks
and re-latch against the old content. Both hooks sit at the exact instant
parsed_contentis replaced; the async one is gated onfull_parseso streamingappends are unaffected.
Verified: the same repro after the fix ends at
max_off = 21 314, the trueheight, and a 500-tick wheel sweep reaches the final block. No gpui core change;
crates/base/src/text/state.rsonly, +25 lines.