in src/language/providers/utils.ts [356:415]
export function checkMultiLineTag(
document: vscode.TextDocument,
position: vscode.Position,
itemsOnLine: number,
nsPrefix: string,
tagPos: number,
tagLine: number,
tag: string,
isDfdlTag = false
): [boolean, boolean] {
if (nsPrefix === 'dfdl:') {
isDfdlTag = true
}
if (itemsOnLine > 1) {
return [false, isDfdlTag]
}
let currentLine = position.line
let openTagLine = position.line
let closeTagLine = position.line
const origText = document.lineAt(currentLine).text
let currentText = origText
//the current line doesn't have the self close symbol
if (!currentText.endsWith('/>')) {
while (currentText.trim() === '' || !currentText.includes('<')) {
--openTagLine
currentText = document.lineAt(openTagLine).text
if (currentText.includes('/>')) {
closeTagLine = openTagLine
}
}
if (
currentText.indexOf('<' + nsPrefix + tag) !== -1 &&
currentText.indexOf('>') === -1 &&
currentText.indexOf('<' + nsPrefix + tag) &&
openTagLine <= position.line &&
closeTagLine >= position.line &&
(origText.indexOf('>') > position.character ||
origText.indexOf('>') === -1)
) {
return [true, isDfdlTag]
}
}
if (currentText.endsWith('/>')) {
let triggerPos = position.character
let tagEndPos = currentText.indexOf('/>')
let triggerLine = position.line
if (
(triggerLine === currentLine && triggerPos < tagEndPos) ||
(triggerLine === tagLine && triggerPos > tagPos && tagPos !== -1) ||
triggerLine < currentLine
) {
return [true, isDfdlTag]
}
}
return [false, isDfdlTag]
}