fix(query-parser): parse file:line after a Windows drive letter - #864
fix(query-parser): parse file:line after a Windows drive letter#864kevin9327 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthrough
ChangesColumn location parsing
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Windows drive-letter paths with line or column suffixes now parse correctly while invalid colon suffixes remain ordinary queries. The focused parser change includes regression coverage and is ready to merge. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The defect
parse_locationdrops the location suffix of any Windows absolute path:parse_column_locationsplits on the first colon and gives up if that onesplit does not yield a location:
On
C:\Users\me\file.rs:12the first colon is the drive separator, solocation_partis\Users\me\file.rs:12, none of the three shapes parse, andthe whole query falls through as plain text. Pasting a path from a compiler
error, a stack trace or grep output into the picker opens the file at line 1
instead of the line named in it — or, since the query still carries the
:12,finds nothing.
Unix absolute paths are unaffected (
/Users/.../file.rs:12has no earliercolon), which is why the single-token guard in
parser.rsthat was written forexactly this shape — "the token looks like an absolute file path with a location
suffix (e.g.
/Users/.../file.rs:12)" — never surfaced it.The fix
Keep scanning colons left to right instead of giving up after the first one.
Left to right is load-bearing:
file:12:4must still split at its first colonso the location part is
12:4, not4.Verification (Windows, default features)
RUSTUP_TOOLCHAINwas pinned to1.98.0-x86_64-pc-windows-msvcbecauserust-toolchain.toml'sstablechannel could not update on this machine.Before,
cargo test -p fff-query-parser --lib -- location:After:
Pins that the scan does not widen anything, all passing before and after:
C:\Users\me\file.rs(colon, no location) stays untouched, as doesfoo:bar— the new assertions in the same test.
test_location_parsingkeepsfile:12:4atPosition { 12, 4 }(notLine(4)),file:12abatNone, and the four range shapes unchanged.test_grep_no_location_parsing_single_token,test_grep_no_location_parsing_multi_tokenand
test_absolute_path_with_location_not_path_segmentare unchanged.cargo test -p fff-query-parser— 89 lib + 3 doc tests passed, 0 failed.cargo test -p fff-search --lib— 159 passed, 0 failed.cargo fmt --all -- --check— clean.cargo clippy -p fff-query-parser --lib— clean.Summary by CodeRabbit
C:\....