Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--write: Avoid line-wrapping YAML flow objects #2022

Merged
merged 2 commits into from Mar 19, 2022

Conversation

cognifloyd
Copy link
Member

When flow-objects (JSON-like YAML maps or lists) get dumped and their line length is too long, they can get wrapped in some very odd places.

This is a flow-style map: { foo: bar }
This is a flow-style list: [0, 1, 2, 3]

So, we calculate how long we expect the line-length might be for flow-style maps and lists.
If it is short enough to fit on one line, we leave it in flow-style.
If the line will (probably) be wrapped, we make that map/list use block-style instead of flow-style.

When flow-objects (JSON-like YAML maps or lists) get dumped and their line
length is too long, they can get wrapped in some very odd places.

So, we calculate how long we expect the line-length might be for
flow-style maps and lists.
If it is short enough to fit on one line, we leave it in flow-style.
If the line will (probably) be wrapped, we make that
map/list use block-style instead of flow-style.
@cognifloyd cognifloyd requested a review from a team as a code owner March 18, 2022 23:27
@cognifloyd cognifloyd self-assigned this Mar 18, 2022
@cognifloyd cognifloyd requested review from ssbarnea and removed request for a team March 18, 2022 23:27
@ssbarnea ssbarnea changed the title --write: Avoid line-wrapping YAML flow objects --write: Avoid line-wrapping YAML flow objects Mar 19, 2022
@ssbarnea ssbarnea enabled auto-merge (squash) March 19, 2022 12:10
@ssbarnea ssbarnea merged commit 6e99861 into ansible:main Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants