diff --git a/src/stringify/stringifyCollection.ts b/src/stringify/stringifyCollection.ts index 326e3afb..7d9e780a 100644 --- a/src/stringify/stringifyCollection.ts +++ b/src/stringify/stringifyCollection.ts @@ -161,7 +161,7 @@ function stringifyFlowCollection( } if (comment) { - str += lineComment(str, commentString(comment), indent) + str += lineComment(str, indent, commentString(comment)) if (onComment) onComment() } return str diff --git a/tests/doc/comments.ts b/tests/doc/comments.ts index 503871fb..e087da04 100644 --- a/tests/doc/comments.ts +++ b/tests/doc/comments.ts @@ -554,6 +554,15 @@ describe('stringify comments', () => { } `) }) + + test('line comment after flow collection (eemeli/yaml#443)', () => { + const doc = YAML.parseDocument(source` + [ value1, value2 ] # comment + `) + expect(String(doc)).toBe(source` + [ value1, value2 ] # comment + `) + }) }) })