Keep interior comments in empty flow collections - #412
Open
BetterAndBetterII wants to merge 1 commit into
Open
BetterAndBetterII wants to merge 1 commit into
BetterAndBetterII wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The emitter change is narrowly scoped, addresses the described failure mode for empty flow collections, and is backed by new regression tests covering the reported cases.
Pull request overview
Fixes emission of interior comments for otherwise-empty flow collections ({} / []) by preventing the START-event FootComment from being flushed before the opening bracket is written, keeping the comment inside the collection as intended (per #406).
Changes:
- Reclassify START-event
FootCommentasHeadCommentfor empty flow sequences/mappings so it isn’t emitted before[/{. - Ensure flow sequences also flush any pending
HeadCommentwhen emitting the closing](covers the empty-sequence case with no items to trigger comment processing). - Add targeted regression coverage in both
emitter.yamland a Go unit test that validates bracket/comment ordering and re-parsability.
File summaries
| File | Description |
|---|---|
| internal/libyaml/emitter.go | Holds interior comments for empty flow collections and emits them inside brackets; adds sequence-end head-comment flush. |
| internal/libyaml/testdata/emitter.yaml | Adds roundtrip regression cases covering empty flow mapping/sequence comment placement scenarios from #406. |
| internal/libyaml/emitter_test.go | Adds a focused unit test ensuring the emitted YAML keeps the comment between the opening and closing brackets and remains parseable. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ingydotnet
requested changes
Sep 2, 2026
ingydotnet
force-pushed
the
fix/empty-flow-comment-406
branch
from
September 2, 2026 22:00
d3b7e5a to
4ec2d11
Compare
ccoVeille
reviewed
Sep 3, 2026
ccoVeille
approved these changes
Sep 4, 2026
ccoVeille
left a comment
Contributor
There was a problem hiding this comment.
Sounds good. Thanks for working on this
BetterAndBetterII
force-pushed
the
fix/empty-flow-comment-406
branch
from
September 5, 2026 14:30
6b209eb to
1bf0b5b
Compare
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.
Empty flow collections were dropping interior comments (
FootCommentwith empty content). Hold that comment asHeadCommentso it survives emit.Fixes #406