Repository navigation
fix(ast-grep): preserve explicitly requested context - #4105
Open
jacobshaw01-del wants to merge 1 commit into
Open
jacobshaw01-del wants to merge 1 commit into
jacobshaw01-del wants to merge 1 commit into
Conversation
📊 Automated PR Analysis
SummaryFixes ast-grep output filtering in RTK so that when a caller explicitly requests context lines via -A/-B/-C (or their long-form equivalents), the raw stdout is preserved instead of being truncated by the generic line cap. Adds a dedicated argument tokenizer-based detection of context flags that correctly distinguishes them from pattern/glob values and paths after Review Checklist
Linked issues: #4015 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
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
ast-grep run -C 2can emit one contiguous block where context and match lines have the samepath:line:contentshape. RTK counted every line against its five-line cap, truncating even the matched expression. The captured reproduction has 10 lines; before this fix, RTK retained only the first five plus an overflow hint.Preserve stdout when the caller explicitly requests context with
-A/--after,-B/--before, or-C/--context. Use the shared argument tokenizer to recognize separate and attached values while excluding pattern/glob values and paths after--. Ordinary searches retain their existing filtering. Update the command summary in the README.Fixes #4015.
Test plan
--boundary; integration coverage verifies exact output preservation and that ordinary searches still filter.cargo fmt --all --check,cargo clippy --locked --all-targets, andcargo test --locked --allpass on macOS arm64 with Rust 1.98.1: 3,814 tests passed, 0 failed, 8 ignored.Explicit context requests intentionally pass through unchanged, following Correctness vs Token Savings. This branch is based directly on
developand is independent of #4104.