Skip to content

Fix CRLF line endings causing extra blank lines between comments#782

Open
cv-dote wants to merge 1 commit intoaws-cloudformation:mainfrom
cv-dote:fix/crlf-comment-formatting
Open

Fix CRLF line endings causing extra blank lines between comments#782
cv-dote wants to merge 1 commit intoaws-cloudformation:mainfrom
cv-dote:fix/crlf-comment-formatting

Conversation

@cv-dote
Copy link
Copy Markdown

@cv-dote cv-dote commented Apr 10, 2026

Issue #, if available: #479

Description of changes:

When a YAML template with Windows-style CRLF (\r\n) line endings is formatted with rain fmt, extra blank lines are inserted between consecutive comment lines. This is because yaml.v3 preserves \r characters in node comment fields, and the formatting logic in format.go treats \r-only lines as non-empty content.

The fix strips \r characters from the input at the beginning of parse.String(), before passing it to yaml.Unmarshal. This normalizes line endings at the pipeline entry point, ensuring CRLF and LF inputs produce identical formatted output.

Design doc: https://gist.github.com/cv-dote/713ad53ab1b29672ae8c3910e496d40d

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.

2 participants