Repository navigation
fix(grep-code): give each context line its own line number - #135
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # REQUIREMENTS.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
grep_codecan give wrong line numbers for context lines. An agent searched a local source (hub-prefix) withis_regexand context lines. All context lines in one block had the same number, for example 47 or 63.The disk scan and the extended scan give correct numbers. The vector-store chunk path does not:
frontmatter.loadsalso removes blank lines at the start of the file. Thus all numbers in the file are too small.start_line=1. A match in a summary gives line numbers that are not in the file.Fix
app/services/code_grep_chunks.py. It puts all chunks of a file together in one line map before the scan. It reads the chunks withget_file_chunkswhen the store has it. It finds the position of a stripped chunk from the lines that are already known. It ignores summary chunks. Each context line now gets its own file line number, and the context can continue into the next chunk.execute_code_grepuses this module for the chunk path._sanitize_match_lineschecks the context numbers. If the numbers do not go up line by line, it counts them again from the match line. This is a safety net for all paths.Tests
tests/test_grep_code_context_lines.py. It tests the indexed-path scan, the extended scan, the chunk path with and withoutget_file_chunks, the sanitizer, and the frontmatter offset.origin/main(chunk path and sanitizer). All pass with this change.REQUIREMENTS.md.🤖 Generated with Claude Code