Repository navigation
fix(parser): preserve CRLF byte offsets during JSON extraction - #3991
Conversation
📊 Automated PR Analysis
SummaryFixes a byte-offset calculation bug in extract_json_object's fallback path where CRLF and mixed line endings caused incorrect offsets, leading to panics on multibyte-prefixed input. Adds extensive regression tests covering line endings, Unicode, indentation, marker variants, and incomplete JSON objects. Review Checklist
Linked issues: #3903 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
pszymkowiak
left a comment
There was a problem hiding this comment.
Thanks @tianhaotian. Reproduced end to end on native Windows with a stub vitest printing CRLF output with an accented line right before a JSON object: develop panics (start byte index 47 is not a char boundary; it is inside 'é', exit 101, output lost), this branch passes the output through and keeps vitest's exit code. Parser and vitest tests pass on Linux and Windows, and CI is green after the branch update.
Summary
extract_json_objectfallback offsets on CRLF and mixed line endings by retaining the actual line terminators; skip indentation so the returned slice begins at{.Fixes #3903. The marker-path regression coverage in #2533 is separate from this fallback-path fix.
Test plan
cargo fmt --all --checkcargo clippy --all-targetscargo test --all— 3572 passed, 8 ignored.cargo test --all -- --ignored --test-threads=1— all 8 additional tests passed.rtk vitestcheck with a failing shim emitting CRLF and an accented path: original diagnostics remain visible and exit status remains 1, with no panic.Validated on macOS arm64 with Rust 1.98.0. The full suite required normal filesystem access for existing initialization tests that write RTK's application-support directory.