How to use the @sourcegraph/codeintellify.AdjustmentDirection.CodeViewToActual function in @sourcegraph/codeintellify

To help you get started, we’ve selected a few @sourcegraph/codeintellify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sourcegraph / sourcegraph / browser / src / libs / phabricator / code_intelligence.ts View on Github external
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)
        })
    )
github sourcegraph / browser-extensions / app / phabricator / code_views.ts View on Github external
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,