fix(web): retain wrapped row heights during edits #10018
main fromrefs/pull/10018/head·merged by juliusmarminge View on GitHubAdding a line near EOF in a large wrapped file discards measured heights for unchanged rows. The file shrinks to single-row estimates and the viewport jumps away from the caret.
Retain measurements before the first changed line. Invalidate changed/shifted rows, use the existing full reset across line-number digit boundaries, and clear old-width measurements during height reconciliation. The existing ResizeManager schedules that work; this adds no observer or synchronous geometry read to the edit callback. Other explicit layout, metric and annotation resets remain intact.
Related to #7907; keep it open for the remaining caret behavior. The highlight and grammar errors were repaired separately in #9902 and #9947.
Verification#
- 55 focused tests pass, including real Editor/VirtualizedFile/ResizeManager behavior with controlled measurements and render-queue drains. The final width regressions fail nine assertions before the repair and pass afterward.
- Seven additional full-reset controls, Enter/undo/redo history receipts, targeted lint and web typecheck pass. FilePreviewPanel retains one unrelated pre-existing effect-dependency lint warning.
- Linux Chromium 152, identical synthetic 8,255-line files, 283px editor, 13px font: cold Enter moves scrollTop 177428 → 16088 before, versus 177428 → 177440 after with the new EOF caret visible. Both insert line 8,256; later native edit/reopen controls also verify disk persistence. Ordinary Undo passes.
- Native explorer resize 283px ↔ 539px and line-count changes 9,999 ↔ 10,000 discard obsolete prefix measurements in both directions. Normal Settings → Appearance destroys the old editor/cache; changing code font to 14px creates a fresh instance, then restoring 13px works.
The baseline was recorded on main with the merged highlight/grammar repairs. Subsequent main changes through f87ecf0c leave this TSX editing path unchanged. The after capture uses 6df6b169. Both clips preserve native speed, with Enter near seven seconds.
Before#

After#

Limits#
This does not fix the existing Redo, resize or digit-boundary caret-scroll policy. Resize invalidation completes after observer delivery and the render drain, not synchronously before an earlier edit. Late in-place settings hydration remains unproven. The original CachyOS/Electron build was not exercised; web and desktop share this editor. Mobile and advanced CodeView editing have no changed T3 caller.
Prepared by GPT 6 Astra via Codex in T3 Code.
Note
Fix wrapped row height retention during edits in VirtualizedFile layout#
- Adds a deterministic test DOM geometry model, resize observer double, and render-frame drain utility so wrapped-layout behavior can be tested without a real browser layout engine
- Covers insertion, deletion, multi-selection edits, undo/redo, annotation changes, metric changes, and width transitions against large wrapped and unwrapped files
- Verifies that unchanged prefix measurements survive edits while changed, shifted, or width-affected rows are invalidated and recomputed
- Tests gutter digit-width boundary crossings (4→5 and 5→4 digits) to confirm prefix measurements are cleared when line-number width changes but preserved when it does not
- All changes are in fileEditorVirtualization.test.ts
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
Approvability#
Verdict: Approved at
6df6b16Macroscope's review found this PR approvable — This is a focused fix to row-height caching and resize reconciliation in the existing wrapped file editor, with no product-default, schema, security, or deployment changes. The production logic is narrowly scoped and backed by extensive regression coverage for edits, undo/redo, resizing, gutter-width boundaries, and cleanup.
Notes:
- No code objects were reviewed. Approvability was decided on eligibility alone.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged this6270a6f
juliusmarminge closed this
Sign in to join this conversation.
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline:
4e59b06· PR result:6df6b16· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.