diff --git a/src/compose/resolve-props.ts b/src/compose/resolve-props.ts index 4ecab4d7..20a1590e 100644 --- a/src/compose/resolve-props.ts +++ b/src/compose/resolve-props.ts @@ -88,7 +88,7 @@ export function resolveProps( case 'newline': if (atNewline) { if (comment) comment += token.source - else spaceBefore = true + else if (!found || indicator !== 'seq-item-ind') spaceBefore = true } else commentSep += token.source atNewline = true hasNewline = true diff --git a/tests/doc/comments.ts b/tests/doc/comments.ts index f9aa4fff..aca037ca 100644 --- a/tests/doc/comments.ts +++ b/tests/doc/comments.ts @@ -685,6 +685,29 @@ describe('blank lines', () => { expect(String(doc)).toBe('- a\n\n- b\n\n- c\n') }) + test('between seq indicator and value (#590)', () => { + const src = source` + key: + - + - a + + - + - + b + ` + const doc = YAML.parseDocument(src) + expect(String(doc)).toBe( + source` + key: + -· + - a + + -· + - b + `.replace(/·/g, ' ') + ) + }) + test('between seq items with leading comments', () => { const src = source` #A