You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The README.md includes agent notes on the alleged cause and possible solutions. I also paste it below:
Notes
Mechanism
Changing the lineAnnotations array identity makes VirtualizedFileDiff.syncLineAnnotations call resetLayoutCache(),
which wipes all measured heightDeltas for the file (here: 60
annotation rows ≈ 28px each), even though annotations never renumber
lines.
The file re-renders at estimated line heights synchronously in the
React commit (and forces a reflow mid-commit), so content above the
viewport transiently shrinks by the forgotten corrections.
Chromium's native scroll anchoring (overflow-anchor: auto, the
default on the scroll container) "corrects" scrollTop against that
transient layout. The virtualizer then re-measures only the rows near
the new position, so nothing ever moves the scroll back.
Two independent changes each make the jump disappear, pointing at the
two halves of the bug:
overflow-anchor: none on the scroll container — this is exactly
what CodeView (advanced mode) does in setup(), plus its own
anchor-capture/correction per render pass, which is why CodeView
apps don't hit this. Simple mode never got that treatment.
Preserving heightDeltas across annotation-only resets (they stay
valid — annotation changes don't shift line indexes). Document edits
(applyDocumentChange, the other reset site) need the keys remapped
by the edit's line delta instead — the transform the editor already
applies to annotations — plus the capturePendingLayoutAnchor
bracket that advanced mode has and simple mode lacks, to absorb the
residual error around the caret.
Inserting an annotation with many hunks above causes a scroll jump. This affects
FileDiff, notCodeView.Reproduction
Source: diffs-jump.tar.gz
The README.md includes agent notes on the alleged cause and possible solutions. I also paste it below:
Notes
Mechanism
lineAnnotationsarray identity makesVirtualizedFileDiff.syncLineAnnotationscallresetLayoutCache(),which wipes all measured
heightDeltasfor the file (here: 60annotation rows ≈ 28px each), even though annotations never renumber
lines.
React commit (and forces a reflow mid-commit), so content above the
viewport transiently shrinks by the forgotten corrections.
overflow-anchor: auto, thedefault on the scroll container) "corrects"
scrollTopagainst thattransient layout. The virtualizer then re-measures only the rows near
the new position, so nothing ever moves the scroll back.
Two independent changes each make the jump disappear, pointing at the
two halves of the bug:
overflow-anchor: noneon the scroll container — this is exactlywhat
CodeView(advanced mode) does insetup(), plus its ownanchor-capture/correction per render pass, which is why CodeView
apps don't hit this. Simple mode never got that treatment.
heightDeltasacross annotation-only resets (they stayvalid — annotation changes don't shift line indexes). Document edits
(
applyDocumentChange, the other reset site) need the keys remappedby the edit's line delta instead — the transform the editor already
applies to annotations — plus the
capturePendingLayoutAnchorbracket that advanced mode has and simple mode lacks, to absorb the
residual error around the caret.
Demo
diffs-jump.mp4