in src/yaml/yamlUtils.ts [412:457]
function getForwardOffsetData(text: string, offset: number, initialNumberOfSpaces: number) {
let isWithinCatchRetryState = false
let hasCatchPropSibling = false
let hasRetryPropSibling = false
let beginLineOffset = offset
// Iterate the text forwards from the offset
for (let i = offset; i <= text.length; i++) {
if (text[i] === '\n') {
const lineText = text.slice(beginLineOffset + 1, i)
const trimmedLine = lineText.trim()
const numberOfPrecedingSpaces = getNumberOfLeftSpaces(lineText)
beginLineOffset = i
// Ignore empty lines
if (trimmedLine.length === 0) {
continue
}
// If number of spaces lower than that of the cursor
// it is a parent property or a sibling of parent property
if (numberOfPrecedingSpaces < initialNumberOfSpaces) {
break
// If number of spaces is higher than that of the cursor it means it is a child
// of the property or of its siblings
} else if (numberOfPrecedingSpaces > initialNumberOfSpaces) {
continue
}
hasCatchPropSibling = trimmedLine.startsWith(CATCH_PROP_STRING) || hasCatchPropSibling
hasRetryPropSibling = trimmedLine.startsWith(RETRY_PROP_STRING) || hasRetryPropSibling
const isCatchRetryState = CATCH_RETRY_STATE_REGEX.test(trimmedLine)
if (isCatchRetryState) {
isWithinCatchRetryState = true
}
}
}
return {
isWithinCatchRetryState,
hasCatchPropSibling,
hasRetryPropSibling,
}
}