Skip to content

[Bug]: Grep tool content mode always returns 'No matches found' on Windows — drive letter breaks regex parsing #2962

@winocreative

Description

@winocreative

Description

The Grep tool's content output mode always returns "No matches found" on Windows, even when matches clearly exist. files_with_matches and count modes work correctly.

Root Cause

In dist/index.js line ~112587, the parseOutput function uses this regex to parse rg output:

const match = line.match(/^(.+?):(\d+):(.*)$/);

On Windows, ripgrep returns paths like C:\Projects\Foo\bar.cpp:42:some content.

The regex matches C as the file group, then expects \d+ after the next colon — but encounters \Projects\... instead. Every line fails to parse, resulting in an empty matches array → "No matches found".

Why other modes work:

Mode Why it works
files_with_matches Uses --files-with-matches flag → rg returns paths only, parsed with filesOnly=true which doesn't use the broken regex
count Uses separate parseCountOutput which matches file:number — still broken on Windows but runRgCount uses --count flag producing C:\...\file.cpp:42 which happens to work differently
content Uses parseOutput with the broken regex → always fails on Windows

Suggested fix:

// Handle Windows drive letters (e.g., C:\path\file.cpp:42:content)
const match = line.match(/^(.+?):(\d+):(.*)$/);
// Should be something like:
const match = line.match(/^([a-zA-Z]:.+?):(\d+):(.*)$/);
// Or use rg's --field-match-separator to avoid colon ambiguity:
// rg --field-match-separator='|' → C:\path\file.cpp|42|content

Steps to Reproduce

  1. On Windows, use oh-my-openagent (v3.14.0) with OpenCode
  2. Call Grep tool with output_mode: "content" on any file with known content
  3. Observe "No matches found" even though files_with_matches mode finds the file

Environment

  • oh-my-openagent: 3.14.0
  • OpenCode: 1.3.7
  • OS: Windows 11 (x64)
  • rg: Both bundled (14.1.1) and system (15.1.0) present and working from shell

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions