Repository navigation
fix(core): preserve CRLF in patch updates - #56128
Parker-Fawcett wants to merge 3 commits into
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
This fixes the bug. I reproduced #54605 end to end with a simulated model calling the patch tool on a CRLF file. On the base, the patched lines came back as LF and the untouched line stayed CRLF. With this PR, every line stays CRLF. The new tests pass, and the six CRLF derive cases and the CRLF+BOM move test fail on the base. packages/util type-checks.
The public API is unchanged: this only changes what Patch.derive writes.
I found nothing blocking. The patch parser already strips \r from hunk lines, so splitting on \r\n can't produce a doubled \r, and context matching still works. Files with mixed line endings behave as before, so patched lines there are still written as LF; that's a reasonable scope for this fix. The nine-case test.each table is more than a 6-line fix needs. A CRLF replacement, a CRLF file with no final newline, and the unchanged LF and mixed-file cases would cover it, and the other cases could be dropped.
Fixes #45926


Issue for this PR
Closes #54605
Type of change
What does this PR do?
Preserve CRLF when the patch tool updates a uniformly CRLF file.
Patch.deriveuses the source newline for splitting and joining, and terminates trailing blank lines so they survive reconstruction. LF and mixed-ending files retain their existing behavior.How did you verify your code works?
bun run checkpass, including lint and all 35 typechecks.Screenshots / recordings
N/A — file content behavior.
Checklist