Conversation
A newly created file used LF whenever the model's content carried no CRLF, so files written on Windows ended up with LF endings while native tooling uses CRLF. Existing files were unaffected: their recorded line endings already win. platformLineEnding() (file-utils) now supplies the default for created files, mirroring the existing detectLineEndings() helper for reads. On LF platforms this is a no-op. Tests cover the CRLF/LF branches of the helper, a created file matching the platform ending, and an existing CRLF file keeping its endings.
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.
Problem
A newly created file was written with LF endings whenever the model's content carried no CRLF:
Created files have no existing EOL to preserve, so on Windows they ended up with LF while native tooling (and the files a user's editor creates) use CRLF. Existing files were unaffected — their recorded line endings already win, and reading already has
detectLineEndings()for exactly that purpose.Fix
platformLineEnding()inpackages/core/src/common/file-utils.tssupplies the default for created files. It mirrorsdetectLineEndings()on the read side and takes the platform EOL as an injectable parameter so both branches are testable off-Windows. On LF platforms the behaviour is unchanged (no-op).Tests
New
packages/core/src/tests/write-handler-line-endings.test.ts:platformLineEnding("\r\n")/platformLineEnding("\n")→CRLF/LF(both branches, any host platform);Verification:
node src/tests/run-tests.mjs(core): 385 tests, 383 pass, 0 fail (2 skipped);npm run typecheck,npm run lint,prettier --checkclean; pre-commit hook passed.