fix: correctly extract context snippets for case-insensitive matches - #19
Conversation
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>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
💡 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".
| .build() | ||
| { | ||
| if let Some(m) = re.find(text) { | ||
| return Some(excerpt_around(text, m.start(), m.len(), 140)); |
There was a problem hiding this comment.
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 👍 / 👎.
The previous implementation of
first_matching_snippetusedmatch_indicesfor case-sensitive searching. When falling back to a case-insensitive search, it simply checked if the query existed usingcontains()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
regexto find the exact byte offsets of a case-insensitive match, allowingexcerpt_aroundto extract the correct context where the matching text actually resides.PR created automatically by Jules for task 6030447735836127145 started by @insign