fix(grep): handle Windows drive-letter paths and CRLF in parseOutput#3321
Merged
code-yeongyu merged 1 commit intocode-yeongyu:devfrom Apr 15, 2026
Merged
Conversation
Contributor
|
All contributors have signed the CLA. Thank you! ✅ |
There was a problem hiding this comment.
No issues found across 1 file
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: The fix safely addresses Windows-specific path and line-ending issues using non-breaking regex fallbacks and carriage return stripping, with no impact on Unix systems.
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
Contributor
Author
|
recheck |
The grep tool's content and count output modes always returned 'No
matches found' on Windows due to two issues:
1. Regex ^(.+?):(\d+):(.*)$ fails on Windows paths like
C:\path\file.ts:42:content because lazy .+? matches only 'C',
then \d+ fails on '\path\...'
2. ripgrep outputs CRLF line endings on Windows. After split('\n'),
trailing \r breaks the $ anchor in the regex, causing every
line to fail matching.
Fix: update parseOutput and parseCountOutput regexes to handle
drive-letter prefixes ([A-Za-z]:[\/]), and strip trailing \r
from each line before matching.
Note: PR code-yeongyu#2976 attempted to fix (1) with --path-separator=/ but
this flag gets expanded by MSYS2/Git Bash to a full path, causing
a separate rg error. This PR avoids --path-separator entirely.
Closes code-yeongyu#2962
82ca72a to
b0b19f3
Compare
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.
Summary
Fixes grep tool
contentandcountoutput modes always returning "No matches found" on Windows.Closes #2962
Root Cause (two issues)
1. Drive-letter regex failure
ripgrep outputs paths like
C:\path\file.ts:42:content. The regex^(.+?):(\d+):(.*)$matchesCas the file group (lazy.+?stops at the first:), then\d+fails on\path\....2. CRLF line endings (missed by PR #2976)
ripgrep outputs
\r\non Windows. Aftersplit("\n"), each line retains a trailing\r. The$anchor in the regex does not match before\r, so every line fails.PR #2976 addressed issue 1 with
--path-separator=/, but this flag gets expanded by MSYS2/Git Bash into a full path (C:/Program Files/Git/), causing a separate rg error. It also did not address issue 2.Fix
parseOutputandparseCountOutputregexes to handle drive-letter prefixes:^([A-Za-z]:[\\/].*?|.+?):(\d+):(.*)$\rfrom each line before matching:line.replace(/\r$/, "")--path-separatorflag (avoids MSYS2 expansion issue)Why this doesn't break Linux/Mac
\rstrip is a no-op when\ris absent([A-Za-z]:[\\/].*?|.+?)— when no drive letter exists, it falls back to the original.+?behaviorTesting
Verified on Windows 11 + Git Bash + ripgrep 15.1.0 + oh-my-openagent 3.16.0:
contentcountfiles_with_matchesSummary by cubic
Fixes Windows parsing in the grep tool so
contentandcountmodes return correct matches instead of "No matches found" by handling drive-letter paths and CRLF line endings.\rfrom each output line before matching.parseOutputandparseCountOutputregexes to supportC:\...paths.--path-separatorusage to avoid MSYS2/Git Bash path expansion.Written for commit b0b19f3. Summary will update on new commits.