@stoplight/yaml
Advanced tools
Comparing version 2.5.1 to 2.6.0
@@ -9,5 +9,8 @@ "use strict"; | ||
return; | ||
return getLoc(lineMap, { start: getStartPosition(node), end: getEndPosition(node) }); | ||
return getLoc(lineMap, { | ||
start: getStartPosition(node, lineMap.length > 0 ? lineMap[0] : 0), | ||
end: getEndPosition(node), | ||
}); | ||
}; | ||
function getStartPosition(node) { | ||
function getStartPosition(node, offset) { | ||
if (node.parent && node.parent.kind === yaml_ast_parser_1.Kind.MAPPING) { | ||
@@ -21,2 +24,5 @@ if (node.parent.value === null) { | ||
} | ||
if (node.parent === null && offset - node.startPosition === 0) { | ||
return 0; | ||
} | ||
return node.startPosition; | ||
@@ -28,3 +34,3 @@ } | ||
const { items } = node; | ||
if (items.length !== 0) { | ||
if (items.length !== 0 && items[items.length - 1] !== null) { | ||
return getEndPosition(items[items.length - 1]); | ||
@@ -44,3 +50,3 @@ } | ||
case yaml_ast_parser_1.Kind.SCALAR: | ||
if (node.parent.kind === yaml_ast_parser_1.Kind.MAPPING && node.parent.value === null) { | ||
if (node.parent !== null && node.parent.kind === yaml_ast_parser_1.Kind.MAPPING && node.parent.value === null) { | ||
return node.parent.endPosition; | ||
@@ -47,0 +53,0 @@ } |
{ | ||
"name": "@stoplight/yaml", | ||
"version": "2.5.1", | ||
"version": "2.6.0", | ||
"description": "Useful functions when working with YAML.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43685
424