feat(web): scroll to exact line when focusing a key change#31
Conversation
Add scrollToLine to FileDiffList that auto-expands collapsed files, waits for shadow DOM rendering, and scrolls the target diff line into view. Update hunk highlight overlay to measure line rects across number + content columns for accurate positioning.
There was a problem hiding this comment.
Code Review
This pull request enhances the diff viewer by implementing a robust scrollToLine functionality that handles collapsed files and asynchronous shadow DOM rendering. It also introduces utility functions for more accurate line highlighting by including the line number gutter in the bounding rectangle. Feedback focuses on optimizing DOM element lookups in large diffs and improving the lifecycle management of scroll-related observers and timers to ensure immediate execution and proper cleanup.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2ab1bc8. Configure here.

Summary
When a user focuses a key change, the view now scrolls to the exact diff line instead of just scrolling to the file header. The hunk highlight overlay also measures line rects more accurately across number and content columns.
Changes
scrollToLineandcancelScrollToLinetoFileDiffListHandle, with logic to auto-expand collapsed files, wait for shadow DOM rendering, and scroll the target line into viewgetHighlightLineRectand helpers (findLineRow,findLineNumberElement) inhunk-highlight-overlay.tsxfor accurate rect measurement across line number + content columnsChapterDetailContentto callscrollToLineinstead ofscrollToFilewhen focusing a key changegetHighlightLineRectand the helper functionsTesting