Conversation
read shows the model LF-only text, and apply_patch spliced those LF lines into CRLF files, converting the touched region to mixed endings. When the splice point is CRLF, derive now carries the file's endings onto the inserted lines. Replacement regions use their own majority; insertions reference the adjacent line.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR:
The other results (#4604 and #20217) appear to be older, related PRs about CRLF handling but are not current duplicates of this PR. |
Author
pengzh1
force-pushed
the
fix/issue-45926
branch
from
August 28, 2026 14:53
ff3051e to
5ed1b1c
Compare
6 tasks
Author
|
Closing this for now — I want to focus on a time-sensitive upstream fix. The branch stays available; I may revisit if the underlying CRLF handling changes. |
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.
Issue for this PR
Closes #45926
Type of change
What does this PR do?
Patch.derivesplit the original on\n, so a CRLF file's lines kept trailing\rwhile the model's new lines are LF-only (read never shows\r). Splicing the hunk replaced the touched CRLF lines with LF lines, turning a consistently-CRLF file into mixed endings.derivenow checks the splice point: when the replaced region (or, for pure insertions, the adjacent line) is CRLF, the inserted lines carry\rtoo. LF files and mixed files keep their previous behavior.How did you verify your code works?
Added three unit tests in
packages/core/test/patch.test.ts, including the exact repro from the issue (derive("f", [{oldLines:["foo"], newLines:["FOO"]}], "foo\r\nbar\r\n")now yields"FOO\r\nbar\r\n"); they fail on unfixed dev. Existingpatch.test.ts+tool-apply-patch.test.ts(18 tests) green,tsgo --noEmitclean.Screenshots / recordings
Tool behavior fix, no UI.
Checklist