Comparing version 2.1.2 to 2.1.3
@@ -14,2 +14,3 @@ import { Pair } from '../nodes/Pair.js'; | ||
let offset = bm.offset; | ||
let commentEnd = null; | ||
for (const collItem of bm.items) { | ||
@@ -34,3 +35,3 @@ const { start, key, sep, value } = collItem; | ||
if (!keyProps.anchor && !keyProps.tag && !sep) { | ||
// TODO: assert being at last item? | ||
commentEnd = keyProps.end; | ||
if (keyProps.comment) { | ||
@@ -105,3 +106,5 @@ if (map.comment) | ||
} | ||
map.range = [bm.offset, offset, offset]; | ||
if (commentEnd && commentEnd < offset) | ||
onError(commentEnd, 'IMPOSSIBLE', 'Map comment with trailing content'); | ||
map.range = [bm.offset, offset, commentEnd ?? offset]; | ||
return map; | ||
@@ -108,0 +111,0 @@ } |
@@ -10,2 +10,3 @@ import { YAMLSeq } from '../nodes/YAMLSeq.js'; | ||
let offset = bs.offset; | ||
let commentEnd = null; | ||
for (const { start, value } of bs.items) { | ||
@@ -19,7 +20,6 @@ const props = resolveProps(start, { | ||
}); | ||
offset = props.end; | ||
if (!props.found) { | ||
if (props.anchor || props.tag || value) { | ||
if (value && value.type === 'block-seq') | ||
onError(offset, 'BAD_INDENT', 'All sequence items must start at the same column'); | ||
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column'); | ||
else | ||
@@ -29,3 +29,3 @@ onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator'); | ||
else { | ||
// TODO: assert being at last item? | ||
commentEnd = props.end; | ||
if (props.comment) | ||
@@ -38,3 +38,3 @@ seq.comment = props.comment; | ||
? composeNode(ctx, value, props, onError) | ||
: composeEmptyNode(ctx, offset, start, null, props, onError); | ||
: composeEmptyNode(ctx, props.end, start, null, props, onError); | ||
if (ctx.schema.compat) | ||
@@ -45,3 +45,3 @@ flowIndentCheck(bs.indent, value, onError); | ||
} | ||
seq.range = [bs.offset, offset, offset]; | ||
seq.range = [bs.offset, offset, commentEnd ?? offset]; | ||
return seq; | ||
@@ -48,0 +48,0 @@ } |
@@ -16,2 +16,3 @@ 'use strict'; | ||
let offset = bm.offset; | ||
let commentEnd = null; | ||
for (const collItem of bm.items) { | ||
@@ -36,3 +37,3 @@ const { start, key, sep, value } = collItem; | ||
if (!keyProps.anchor && !keyProps.tag && !sep) { | ||
// TODO: assert being at last item? | ||
commentEnd = keyProps.end; | ||
if (keyProps.comment) { | ||
@@ -107,3 +108,5 @@ if (map.comment) | ||
} | ||
map.range = [bm.offset, offset, offset]; | ||
if (commentEnd && commentEnd < offset) | ||
onError(commentEnd, 'IMPOSSIBLE', 'Map comment with trailing content'); | ||
map.range = [bm.offset, offset, commentEnd ?? offset]; | ||
return map; | ||
@@ -110,0 +113,0 @@ } |
@@ -12,2 +12,3 @@ 'use strict'; | ||
let offset = bs.offset; | ||
let commentEnd = null; | ||
for (const { start, value } of bs.items) { | ||
@@ -21,7 +22,6 @@ const props = resolveProps.resolveProps(start, { | ||
}); | ||
offset = props.end; | ||
if (!props.found) { | ||
if (props.anchor || props.tag || value) { | ||
if (value && value.type === 'block-seq') | ||
onError(offset, 'BAD_INDENT', 'All sequence items must start at the same column'); | ||
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column'); | ||
else | ||
@@ -31,3 +31,3 @@ onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator'); | ||
else { | ||
// TODO: assert being at last item? | ||
commentEnd = props.end; | ||
if (props.comment) | ||
@@ -40,3 +40,3 @@ seq.comment = props.comment; | ||
? composeNode(ctx, value, props, onError) | ||
: composeEmptyNode(ctx, offset, start, null, props, onError); | ||
: composeEmptyNode(ctx, props.end, start, null, props, onError); | ||
if (ctx.schema.compat) | ||
@@ -47,3 +47,3 @@ utilFlowIndentCheck.flowIndentCheck(bs.indent, value, onError); | ||
} | ||
seq.range = [bs.offset, offset, offset]; | ||
seq.range = [bs.offset, offset, commentEnd ?? offset]; | ||
return seq; | ||
@@ -50,0 +50,0 @@ } |
{ | ||
"name": "yaml", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "author": "Eemeli Aro <eemeli@gmail.com>", |
649153
17339