Skip to content

Commit 12f243c

Browse files
eemeliNathan Fenner
authored and
Nathan Fenner
committed
fix(lexer): Reset flow-key flag on comma in flow collection (fixes eemeli#316)
1 parent 37adff7 commit 12f243c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/parse/lexer.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,11 @@ export class Lexer {
405405
}
406406
}
407407
let n = 0
408-
while (line[n] === ',')
409-
n += (yield* this.pushCount(1)) + (yield* this.pushSpaces(true))
408+
while (line[n] === ',') {
409+
n += yield* this.pushCount(1)
410+
n += yield* this.pushSpaces(true)
411+
this.flowKey = false
412+
}
410413
n += yield* this.pushIndicators()
411414
switch (line[n]) {
412415
case undefined:

tests/lexer.ts

+6
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ test('plain scalar + CRLF + comment', () => {
1616
const res = Array.from(new Lexer().lex(src))
1717
expect(res).toEqual(['\u0002', '\u001f', 'foo', '\r\n', '# bar'])
1818
})
19+
20+
test('Scalar starting with : after flow-ish key in preceding node in flow collection', () => {
21+
const src = '[[], :@]'
22+
const res = Array.from(new Lexer().lex(src))
23+
expect(res).toEqual(['\u0002', '[', '[', ']', ',', ' ', '\u001f', ':@', ']'])
24+
})

0 commit comments

Comments
 (0)