Skip to content

fix(ast-grep): parse Windows drive-letter paths - #4060

Open
Raymondriter wants to merge 1 commit into
rtk-ai:developfrom
Raymondriter:fix/ast-grep-windows-paths
Open

Raymondriter wants to merge 1 commit into
rtk-ai:developfrom
Raymondriter:fix/ast-grep-windows-paths

Conversation

@Raymondriter

Copy link
Copy Markdown
Contributor

Summary

  • MATCH_LINE_RE now accepts an optional drive prefix (C:\ or C:/) ahead of the path. Absolute-path invocations on Windows parse and get grouped instead of falling back to full passthrough with 0% savings.
  • The separator after the drive letter is required, so a one-letter relative file such as a:12:34 still reads as line 12 of a rather than a drive.
  • Updated the unparsed_signal doc comment: POSIX paths that contain a colon are still left to the passthrough guard.

Closes #4017

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test (3783 passed, 0 clippy warnings)
  • New test_windows_drive_letter_paths_are_grouped (C:\… and D:/… shapes) fails on develop and passes with the fix
  • New test_single_letter_file_is_not_a_drive guards the a:12:34 ambiguity
  • Manual run on a Windows host. Not done: I verified the regex behaviour through the unit tests, and Windows CI covers the build.

🤖 Generated with Claude Code

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added ast-grep bug Something isn't working windows labels Sep 14, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes the ast-grep result parsing regex so Windows absolute paths with drive letters (e.g. C:\src\a.rs) are correctly matched and grouped instead of falling back to unfiltered passthrough. Adds tests covering both the drive-letter grouping case and the ambiguous single-letter relative file case (a:12:34), and updates the related doc comment.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4017


Analyzed automatically by wshm · This is an automated analysis, not a human review.

@pszymkowiak

Copy link
Copy Markdown
Collaborator

Hey @Raymondriter, thanks for this, the drive-letter case is still broken on develop (MATCH_LINE_RE is unchanged). The branch conflicts after several refactors of ast_grep_cmd.rs since September. Could you rebase on develop? The change itself should carry over as is. I'll run it on a Windows machine with real ast-grep output once it's updated.

MATCH_LINE_RE used `[^:]+` for the path, which cannot cross the colon in
`C:\src\a.rs:12:...`. ast-grep echoes absolute path arguments verbatim,
so on Windows no line parsed and the filter fell back to full
passthrough with no savings.

Allow an optional drive prefix followed by `\` or `/`. Requiring the
separator keeps a one-letter relative file such as `a:12:34` reading as
line 12 of `a`.

Closes rtk-ai#4017

Signed-off-by: Raymond Riter <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
@Raymondriter
Raymondriter force-pushed the fix/ast-grep-windows-paths branch from f096717 to 360027e Compare November 30, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ast-grep bug Something isn't working windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk ast-grep: Windows absolute paths never parse, so the filter degrades to a full passthrough with no savings

2 participants