Skip to content

fix(differ): prevent auto-scroll from overwriting comment jump on file switch#507

Merged
matt2e merged 4 commits intomainfrom
misplaced-comment
Mar 27, 2026
Merged

fix(differ): prevent auto-scroll from overwriting comment jump on file switch#507
matt2e merged 4 commits intomainfrom
misplaced-comment

Conversation

@matt2e
Copy link
Contributor

@matt2e matt2e commented Mar 27, 2026

Summary

  • Fix misplaced comments when switching files by ensuring lastAutoScrolledFile is updated even when auto-scroll is skipped due to a pending comment/line jump
  • Defer jump-to-comment scroll until after DOM measurement to ensure correct positioning

Test plan

  • Switch between files with inline comments and verify comments appear at the correct position
  • Verify auto-scroll still works correctly when no comment jump is pending

🤖 Generated with Claude Code

matt2e and others added 4 commits March 27, 2026 11:25
When switching files via a sidebar comment click, the jump-to-comment
effect fired before dimension effects measured the new file's DOM,
causing scrollToRow to use stale dimensions and land at the wrong
position. Wrap both jump-to-comment and jump-to-line scroll calls in
requestAnimationFrame to let dimension effects run first, matching the
existing pattern used by the auto-scroll effect.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…itch

Reverts the requestAnimationFrame wrapping from 85b5f16 (which caused
scrolling to the top instead of the comment) and adds [jump-comment]
console.info logs throughout the jump-to-comment flow:
- handleSelectComment trigger and selectFile resolution
- setAlignments effect and scroll reset
- auto-scroll effect (skip/fire)
- dimension measurement effects
- focusCommentInViewer with span/displayRange
- scrollController.scrollToRow, scrollTo, setAlignments

Filter in devtools with: [jump-comment]

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…e switch

When the auto-scroll effect skipped due to a pending jumpToComment, it
did not set lastAutoScrolledFile. After the jump-to-comment effect
consumed the token and scrolled to the correct position, the
lastHandledJumpToken change caused the auto-scroll effect to re-run.
Since lastAutoScrolledFile was never set for the new file, it proceeded
to schedule a rAF that scrolled to the first hunk, overwriting the
comment position.

Set lastAutoScrolledFile in both jump-pending skip paths so the
auto-scroll effect cannot re-fire for the same file after a jump
completes. Also removes the diagnostic [jump-comment] console.info
logging from the previous commit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matt2e matt2e requested review from baxen and wesbillman as code owners March 27, 2026 00:54
@matt2e matt2e merged commit 62ae28a into main Mar 27, 2026
5 checks passed
@matt2e matt2e deleted the misplaced-comment branch March 27, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant