Adding annotation in `FileDiff` + `Virtualizer` causes scroll jump
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- frontend, performance
Research direction
Start with the attached reproduction and README notes, then trace how FileDiff and Virtualizer handle annotation updates, especially syncLineAnnotations and resetLayoutCache. Compare this with CodeView's scroll handling and investigate whether annotation-only changes invalidate measured heights. Done means adding annotations above the viewport no longer causes a scroll jump in the reproduction.
Written by the indexing model from the issue text.
Description
Inserting an annotation with many hunks above causes a scroll jump. This affects FileDiff, not CodeView.
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
- Changing the
lineAnnotationsarray identity makes
VirtualizedFileDiff.syncLineAnnotationscallresetLayoutCache(),
which wipes all measuredheightDeltasfor 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"scrollTopagainst 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: noneon the scroll container — this is exactly
whatCodeView(advanced mode) does insetup(), 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
heightDeltasacross 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 thecapturePendingLayoutAnchor
bracket that advanced mode has and simple mode lacks, to absorb the
residual error around the caret.
Demo
https://github.com/user-attachments/assets/696676e3-a390-4f18-9b83-63e93b889915
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 226
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 33
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pierrecomputer/pierre
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pierrecomputer/pierre#1187 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pierrecomputer/pierre#1150 · 3 comments ·
Maintainers usually reply within 1 day
-
Bug: WebKit crashes when drag-selecting text that auto-scrolls a diff (gutter-utility re-parented mid-drag)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
pierrecomputer/pierre#1184 · 4 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 63/100
pierrecomputer/pierre#1172 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 54/100
pierrecomputer/pierre#1171 · 2 comments ·
Maintainers usually reply within 1 day
All issues in pierrecomputer/pierre
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
area:cowork area:desktop documentation enhancement platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
anthropics/claude-code#101720 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
apache/rocketmq-dashboard#6610 ·
Maintainers usually reply within 3 days
-
Add: MS NOWOpencheck:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Global update drops overrideAccess, so Local API updateGlobal fails filterOptions validation (3.90 regression)Possibly taken @PINYOPATTANAWASANPORN claimed this today. Openarea: core Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
payloadcms/payload#18674 · 1 comment ·
Maintainers usually reply within 1 day