Skip to content

fix(yamlfmt): keep fitting flow collections intact - #625

Open
felix-windsor wants to merge 1 commit into
Boeing:feat/3.0from
felix-windsor:fix/yaml-flow-collection-own-line
Open

fix(yamlfmt): keep fitting flow collections intact#625
felix-windsor wants to merge 1 commit into
Boeing:feat/3.0from
felix-windsor:fix/yaml-flow-collection-own-line

Conversation

@felix-windsor

Copy link
Copy Markdown

Closes #623

Summary

  • Give an over-width flow collection the extra room from moving below its mapping key before deciding whether to split its elements.
  • Keep the collection intact when it fits at the deeper value indentation; collections that are still too wide continue to use the existing element-per-line layout.
  • Preserve already-multiline flow collections rather than passing them through the single-line relocation path.
  • Add a regression test for the reported sequence-item shape, including a second formatting pass to pin idempotency.
  • Document the fix in the changelog.

For the issue reproduction, the formatter now produces the same bytes as Prettier 3:

items:
  - labels:
      ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]
    name: x

Validation

  • go vet ./...
  • gofmt -s -l -e . — clean
  • golangci-lint run ./... — 0 issues
  • go generate ./pkg/filetype/...
  • go build -o /dev/null ./cmd/cfv
  • go test -cover -coverprofile coverage.out ./... — all packages passed, 92.3% total coverage
  • npx --yes prettier@3 --parser yaml on the issue reproduction — byte-for-byte match

Implemented and verified with Codex assistance; the final diff and test results were reviewed before submission.

@felix-windsor
felix-windsor requested a review from a team as a code owner August 1, 2026 02:47
@kehoecj kehoecj added OSS Community Contribution Contributions from the OSS Community waiting-on-maintainer-review PR is waiting to be reviewed and functionally tested by the maintainers labels Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OSS Community Contribution Contributions from the OSS Community waiting-on-maintainer-review PR is waiting to be reviewed and functionally tested by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants