Skip to content

Conversation

@braydonk
Copy link
Collaborator

Fixes #254

When yaml.v3 parses a document that's just comments, it ends up parsing no actual nodes and thus loses the comment information. This will now be treated as an edge case and return the original content, in essence not modifying it if the yaml parsed successfully but no nodes are parsed out.

When `yaml.v3` parses a document that's just comments, it ends up
parsing no actual nodes and thus loses the comment information. This
will now be treated as an edge case and return the original content, in
essence not modifying it if the yaml parsed successfully but no nodes are
parsed out.
@braydonk braydonk merged commit 1e2fd2c into google:main Jun 19, 2025
5 checks passed
steeef pushed a commit to steeef/yamlfmt that referenced this pull request Sep 5, 2025
When `yaml.v3` parses a document that's just comments, it ends up
parsing no actual nodes and thus loses the comment information. This
will now be treated as an edge case and return the original content, in
essence not modifying it if the yaml parsed successfully but no nodes are
parsed out.
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.

yamlfmt removes comment from yaml with only a comment

1 participant