Fix ripgrep output parsing on Windows drive-letter paths - #20
Closed
harshdotcom wants to merge 1 commit into
Closed
Conversation
_parse_rg split each line on the first two colons, but ripgrep is invoked with an absolute path — on Windows that starts with a drive letter (C:\...) whose colon was mistaken for the path:line:text separator, so every match reported file "C", line 0, with the line number leaked into the text. Anchor the parse on the numeric :<line>: field with a regex so the drive-letter colon and any colons in the matched text are preserved. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
harshdotcom
force-pushed
the
fix/windows-ripgrep-parse
branch
from
July 23, 2026 20:12
4845937 to
35a24bc
Compare
Collaborator
|
Thanks — you were the first to catch the Windows drive-letter parsing bug, and your fix was correct for the main case. We merged #123, which fixes the emission side instead (--with-filename --null), which also covers colons in filenames and the single-file case where rg omits the filename. Windows grep is now fixed on main, so I'm closing this one. Appreciate the report and fix! |
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.
What
Fixes the
greptool returning corrupted results on Windows when ripgrep is installed._parse_rgsplit each ripgrep output line withline.split(":", 2). ripgrep isinvoked with an absolute search path, which on Windows starts with a drive
letter (
C:\...) — that colon was mistaken for thepath:line:textfieldseparator, so every match reported file
"C", line0, with the real linenumber leaked into the text field.
Fix
Anchor the parse on the numeric
:<line>:field with a regex(
(.+?):(\d+):(.*)), so both the drive-letter colon and any colons inside thematched text are preserved. A plain
rsplit(":", 2)would not work — matchedtext frequently contains colons (e.g.
def hello():).Testing
test_parse_rg_handles_windows_drive_letter_and_colons_in_text(platform-independent — hardcodes a Windows-style line). It fails on the old
split(":", 2)and passes on the fix.Closes #17