Skip to content

Commit ad763fd

Browse files
committed
fix: use the lineWidth option for line breaking in flow collections
This should address issues #288 and #507.
1 parent b7696fc commit ad763fd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/stringify/stringifyCollection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function stringifyFlowCollection(
148148
} else {
149149
if (!reqNewline) {
150150
const len = lines.reduce((sum, line) => sum + line.length + 2, 2)
151-
reqNewline = len > Collection.maxFlowStringSingleLineLength
151+
reqNewline = ctx.options.lineWidth !== 0 && len > ctx.options.lineWidth
152152
}
153153
if (reqNewline) {
154154
str = start

tests/doc/stringify.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ describe('scalar styles', () => {
616616
y,
617617
n
618618
]\n`
619-
expect(String(doc)).toBe(str)
619+
expect(doc.toString({ lineWidth: 1 })).toBe(str)
620620
expect(YAML.parse(str)).toEqual([
621621
true,
622622
false,

0 commit comments

Comments
 (0)