Skip to content

Commit 5af5d3d

Browse files
committed
fix: Use correct argument order when stringifying flow collection comments (fixes #443)
1 parent c914dcc commit 5af5d3d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/stringify/stringifyCollection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function stringifyFlowCollection(
161161
}
162162

163163
if (comment) {
164-
str += lineComment(str, commentString(comment), indent)
164+
str += lineComment(str, indent, commentString(comment))
165165
if (onComment) onComment()
166166
}
167167
return str

tests/doc/comments.js

+9
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,15 @@ describe('stringify comments', () => {
543543
}
544544
`)
545545
})
546+
547+
test('line comment after flow collection (eemeli/yaml#443)', () => {
548+
const doc = YAML.parseDocument(source`
549+
[ value1, value2 ] # comment
550+
`)
551+
expect(String(doc)).toBe(source`
552+
[ value1, value2 ] # comment
553+
`)
554+
})
546555
})
547556
})
548557

0 commit comments

Comments
 (0)