diff --git a/src/parse/parser.ts b/src/parse/parser.ts index 528280fe..fb1453b4 100644 --- a/src/parse/parser.ts +++ b/src/parse/parser.ts @@ -529,7 +529,11 @@ export class Parser { } if (this.indent >= map.indent) { - const atNextItem = !this.onKeyLine && this.indent === map.indent && it.sep + const atNextItem = + !this.onKeyLine && + this.indent === map.indent && + it.sep && + this.type !== 'seq-item-ind' // For empty nodes, assign newline-separated not indented empty tokens to following node let start: SourceToken[] = [] diff --git a/tests/cst.ts b/tests/cst.ts index 7100e8f6..3580c959 100644 --- a/tests/cst.ts +++ b/tests/cst.ts @@ -195,3 +195,9 @@ describe('CST.visit', () => { expect(visits).toBe(3) }) }) + +test('Line comment before unindented block-seq in block-map (eemeli/yaml#525)', () => { + const src = 'a:\n#\n- b' + const [doc] = Array.from(new Parser().parse(src)) + expect(CST.stringify(doc)).toBe(src) +})