Skip to content

Conversation

@weilirs
Copy link
Collaborator

@weilirs weilirs commented Apr 13, 2025

No description provided.

Copy link

@greptile-apps greptile-apps bot left a comment

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

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