Skip to content

feat(web): scroll to exact line when focusing a key change#31

Merged
dastratakos merged 3 commits into
mainfrom
dastratakos/hunk-highlight-overlay
May 5, 2026
Merged

feat(web): scroll to exact line when focusing a key change#31
dastratakos merged 3 commits into
mainfrom
dastratakos/hunk-highlight-overlay

Conversation

@dastratakos
Copy link
Copy Markdown
Contributor

@dastratakos dastratakos commented May 4, 2026

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

  • Add scrollToLine and cancelScrollToLine to FileDiffListHandle, with logic to auto-expand collapsed files, wait for shadow DOM rendering, and scroll the target line into view
  • Extract getHighlightLineRect and helpers (findLineRow, findLineNumberElement) in hunk-highlight-overlay.tsx for accurate rect measurement across line number + content columns
  • Update ChapterDetailContent to call scrollToLine instead of scrollToFile when focusing a key change
  • Add unit tests for getHighlightLineRect and the helper functions

Testing

  • Typecheck, lint, and all 160 tests pass
  • Manual verification needed for scroll-to-line behavior in the browser

Open in Stage

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.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/web/src/components/chapter/hunk-highlight-overlay.tsx Outdated
Comment thread packages/web/src/components/files/file-diff-list.tsx
Comment thread packages/web/src/components/files/file-diff-list.tsx Outdated
Comment thread packages/web/src/components/files/file-diff-list.tsx Outdated
Comment thread packages/web/src/components/files/file-diff-list.tsx
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread packages/web/src/components/chapter/hunk-highlight-overlay.tsx Outdated
@dastratakos dastratakos marked this pull request as ready for review May 5, 2026 03:03
@dastratakos dastratakos merged commit 32879ea into main May 5, 2026
5 checks passed
@dastratakos dastratakos deleted the dastratakos/hunk-highlight-overlay branch May 5, 2026 03:03
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