in src/yaml/aslYamlLanguageService.ts [44:73]
function convertYAMLDiagnostic(yamlDiagnostic: YAMLDocDiagnostic, textDocument: TextDocument): Diagnostic {
const startLoc = yamlDiagnostic.location.start
let endLoc = yamlDiagnostic.location.end
let severity = yamlDiagnostic.severity
// Duplicate positioning returns incorrect end position and needs to be ovewritten
if (yamlDiagnostic.message === YAML_PARSER_MESSAGES.DUPLICATE_KEY) {
const text = textDocument.getText()
// Update severity to error
severity = 1
for (let loc = yamlDiagnostic.location.start; loc < text.length; loc++) {
// Colon and whitespace character signal the end of the key.
if (text.slice(loc, loc + 2).match(/:\s/)) {
endLoc = loc
} else if (text[loc] === '\n') {
break
}
}
}
const startPos = textDocument.positionAt(startLoc)
const endPos = textDocument.positionAt(endLoc)
return {
range: Range.create(startPos, endPos),
message: yamlDiagnostic.message,
severity,
}
}