[FEATURE]: Improve grep output truncation to center match context #9080

Open
opened 2026-02-16 18:11:35 -05:00 by yindo · 1 comment
Owner

Originally created by @mrzys on GitHub (Feb 11, 2026).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Currently, the GrepTool aggressively truncates long lines (>2000 chars) by simply taking the first 2000 characters. Is there a risk that the matched pattern is not in the truncated line?

const truncatedLineText =
    match.lineText.length > MAX_LINE_LENGTH ? match.lineText.substring(0, MAX_LINE_LENGTH) + "..." : match.lineText
outputLines.push(`  Line ${match.lineNum}: ${truncatedLineText}`)
Originally created by @mrzys on GitHub (Feb 11, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request Currently, the [GrepTool](https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/tool/grep.ts#L123) aggressively truncates long lines (>2000 chars) by simply taking the first 2000 characters. Is there a risk that the matched `pattern` is not in the truncated line? ```typescript const truncatedLineText = match.lineText.length > MAX_LINE_LENGTH ? match.lineText.substring(0, MAX_LINE_LENGTH) + "..." : match.lineText outputLines.push(` Line ${match.lineNum}: ${truncatedLineText}`) ```
yindo added the discussion label 2026-02-16 18:11:35 -05:00
Author
Owner

@R44VC0RP commented on GitHub (Feb 11, 2026):

hey @thdxr thoughts on this?

@R44VC0RP commented on GitHub (Feb 11, 2026): hey @thdxr thoughts on this?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9080