Skip to content

Commit

Permalink
fix: use the lineWidth option for line breaking in flow collections
Browse files Browse the repository at this point in the history
This should address issues #288 and #507.
  • Loading branch information
no92 committed Feb 12, 2024
1 parent b7696fc commit ad763fd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/stringify/stringifyCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function stringifyFlowCollection(
} else {
if (!reqNewline) {
const len = lines.reduce((sum, line) => sum + line.length + 2, 2)
reqNewline = len > Collection.maxFlowStringSingleLineLength
reqNewline = ctx.options.lineWidth !== 0 && len > ctx.options.lineWidth
}
if (reqNewline) {
str = start
Expand Down
2 changes: 1 addition & 1 deletion tests/doc/stringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ describe('scalar styles', () => {
y,
n
]\n`
expect(String(doc)).toBe(str)
expect(doc.toString({ lineWidth: 1 })).toBe(str)
expect(YAML.parse(str)).toEqual([
true,
false,
Expand Down

0 comments on commit ad763fd

Please sign in to comment.