Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

feat: search result autoscroll - #515

Open
weilirs wants to merge 4 commits into
reorproject:mainfrom
weilirs:autoscroll
Open

feat: search result autoscroll#515
weilirs wants to merge 4 commits into
reorproject:mainfrom
weilirs:autoscroll

Conversation

@weilirs

@weilirs weilirs commented Apr 13, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PR Summary

This PR implements an autoscroll feature for search results, allowing users to jump directly to relevant content positions when selecting search results.

  • Added position tracking in chunking.ts with new functions that maintain character positions in the original document
  • Extended the database schema in schema.ts with an optional startPos field to store chunk positions
  • Modified DBResultPreview and DBSearchPreview components to pass position information when results are clicked
  • Implemented scrolling logic in FileContext.tsx that intelligently finds the best DOM element to scroll to
  • Added proper error handling with fallbacks when ideal scroll targets can't be found

Greptile AI

7 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +104 to +109
const chunkPosition = stringInfo.text.indexOf(chunkText, currentOffset)

if (chunkPosition !== -1) {
const absolutePosition = stringInfo.pos + chunkPosition

currentOffset = chunkPosition + 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

logic: The currentOffset = chunkPosition + 1 logic might skip content if there are overlapping chunks with identical text. Consider using currentOffset = chunkPosition + chunkText.length to ensure proper progression through the text.

Suggested change
const chunkPosition = stringInfo.text.indexOf(chunkText, currentOffset)
if (chunkPosition !== -1) {
const absolutePosition = stringInfo.pos + chunkPosition
currentOffset = chunkPosition + 1
const chunkPosition = stringInfo.text.indexOf(chunkText, currentOffset)
if (chunkPosition !== -1) {
const absolutePosition = stringInfo.pos + chunkPosition
currentOffset = chunkPosition + chunkText.length

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant