Skip to content

fix: handle CRLF trivia in ordered imports - #1257

Draft
aryansk wants to merge 1 commit into
swiftlang:mainfrom
aryansk:codex/issue-1250-crlf-imports
Draft

fix: handle CRLF trivia in ordered imports#1257
aryansk wants to merge 1 commit into
swiftlang:mainfrom
aryansk:codex/issue-1250-crlf-imports

Conversation

@aryansk

@aryansk aryansk commented Aug 3, 2026

Copy link
Copy Markdown

Fixes #1250

OrderedImports only recognized .newlines trivia when reconstructing lines. SwiftSyntax represents Windows line endings as .carriageReturnLineFeeds, so CRLF separators were kept as trivia and could produce extra blank lines when imports were reordered.

This change treats LF, CR, and CRLF trivia as line boundaries and adds a regression test using CRLF input.

Tests:

  • swift test --parallel
  • swift-format lint --strict Sources/SwiftFormat/Rules/OrderedImports.swift Tests/SwiftFormatTests/Rules/OrderedImportsTests.swift

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extra empty line between import on Windows

1 participant