You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rtk ast-grep: -C/-A/-B context lines are counted as matches, eating the per-file cap and inflating the overflow hint #4015
MATCH_LINE_RE in src/cmds/system/ast_grep_cmd.rs has no way to tell the two apart, so with -C 2 the five-line per-file budget is spent almost entirely on leading context before any match is reached, and the overflow count is inflated by context lines on top of the line-vs-match gap:
$ rtk ast-grep run -p 'LazyLock::new($$$)' -l rust -C 2 src/cmds/system/ctest_cmd.rs
src/cmds/system/ctest_cmd.rs:22:const MAX_FAILED_BLOCK_ENTRIES: usize = ...
src/cmds/system/ctest_cmd.rs:23:
src/cmds/system/ctest_cmd.rs:24:static TEST_RE: LazyLock<Regex> = LazyLock::new(|| {
src/cmds/system/ctest_cmd.rs:25: Regex::new(
src/cmds/system/ctest_cmd.rs:26: r"(?s)^\s*(?:\d+/(\d+)\s+)?Test\s+#(\d+):...
… 27 more match line(s) in src/cmds/system/ctest_cmd.rs
The file holds 6 matches. Asking for context makes the output strictly less useful than not asking for it.
src/cmds/system/search.rs solves this for grep/rg by forcing --null and capturing the separator: ^([^\x00]+)\x00(\d+)([:-]) (search.rs:287, :739), where : means match and - means context. ast-grep has no equivalent separator in plain mode, so the fix probably means either honouring context as a unit attached to its match, or declining to filter when a context flag is present (the way has_format_flag() declines other shapes at search.rs:751).
ast-grep's -C/-A/-B context lines are indistinguishable from match lines in the filter's regex, so they consume the per-file cap and inflate the overflow count; needs a separator-based fix like search.rs's grep/rg handling or disabling filtering when context flags are present.
📁 Relevant files
src/cmds/system/ast_grep_cmd.rs
src/cmds/system/search.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
Activity
rtk-wshm-sync-bot commentedon Sep 13, 2026
🔍 Automated Triage
bugmediumSummary
ast-grep's -C/-A/-B context lines are indistinguishable from match lines in the filter's regex, so they consume the per-file cap and inflate the overflow count; needs a separator-based fix like search.rs's grep/rg handling or disabling filtering when context flags are present.
📁 Relevant files
src/cmds/system/ast_grep_cmd.rssrc/cmds/system/search.rsTriaged automatically by wshm · This is an automated analysis, not a human review.