Skip to content

fix: correctly extract context snippets for case-insensitive matches - #19

Merged
insign merged 1 commit into
mainfrom
improve-context-snippet-search-6030447735836127145
Jun 13, 2026
Merged

fix: correctly extract context snippets for case-insensitive matches#19
insign merged 1 commit into
mainfrom
improve-context-snippet-search-6030447735836127145

Conversation

@insign

@insign insign commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

The previous implementation of first_matching_snippet used match_indices for case-sensitive searching. When falling back to a case-insensitive search, it simply checked if the query existed using contains() and returned a truncated version of the start of the text (truncate_chars). This led to users seeing the beginning of long texts rather than the actual context where their case-insensitive match occurred.

This fix introduces regex to find the exact byte offsets of a case-insensitive match, allowing excerpt_around to extract the correct context where the matching text actually resides.


PR created automatically by Jules for task 6030447735836127145 started by @insign

The previous implementation of `first_matching_snippet` used `match_indices` for case-sensitive searching. When falling back to a case-insensitive search, it simply checked if the query existed using `contains()` and returned a truncated version of the start of the text (`truncate_chars`). This led to users seeing the beginning of long texts rather than the actual context where their case-insensitive match occurred.

This fix introduces `regex` to find the exact byte offsets of a case-insensitive match, allowing `excerpt_around` to extract the correct context where the matching text actually resides.

Co-authored-by: insign <1113045+insign@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0499c80cfc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/context/manager.rs
.build()
{
if let Some(m) = re.find(text) {
return Some(excerpt_around(text, m.start(), m.len(), 140));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the now-dead helper before CI

This replacement removes the only remaining call to truncate_chars; with the helper now private and unused, the repo's make clippy target (cargo clippy --all-targets --all-features -- -D warnings) will treat the resulting dead_code warning as an error and block make precommit/CI. Either delete the helper or keep it used in this fallback path.

Useful? React with 👍 / 👎.

@insign
insign merged commit ae8fd5e into main Jun 13, 2026
8 of 9 checks passed
@insign
insign deleted the improve-context-snippet-search-6030447735836127145 branch June 13, 2026 17:44
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