Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
map(lines => {
const codeElement = diffDomFunctions.getCodeElementFromLineNumber(codeView, position.line, position.part)
if (!codeElement) {
throw new Error('(adjustPosition) could not find code element for line provided')
}
const textContentInfo = getTextContent(codeElement)
const documentLineContent = textContentInfo.textContent
const actualLineContent = lines[position.line - 1]
// See if we should adjust for whitespace changes.
const convertSpaces = convertSpacesToTabs(actualLineContent, documentLineContent)
// Whether the adjustment should add or subtract from the given position.
const modifier = direction === AdjustmentDirection.CodeViewToActual ? -1 : 1
return convertSpaces
? adjustCharacter(
position,
(spacesToTabsAdjustment(documentLineContent) + textContentInfo.adjust) * modifier
)
: adjustCharacter(position, textContentInfo.adjust * modifier)
})
)
map(lines => {
const codeElement = diffDomFunctions.getCodeElementFromLineNumber(codeView, position.line)
if (!codeElement) {
throw new Error('(adjustPosition) could not find code element for line provided')
}
const documentLineContent = codeElement.textContent!
const actualLineContent = lines[position.line - 1]
const convertSpaces = convertSpacesToTabs(
actualLineContent,
documentLineContent.substr(position.part ? 1 : 0)
)
const modifier = direction === AdjustmentDirection.CodeViewToActual ? -1 : 1
console.log(
'convertSpaces',
convertSpaces,
convertSpaces
? {
line: position.line,
character:
position.character + spacesToTabsAdjustment(documentLineContent.substr(1)) * modifier,
}
: position
)
return convertSpaces
? {
line: position.line,