This repository was archived by the owner on Nov 25, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -331,19 +331,22 @@ export const getCodeElementsInRange = ({
331331 *
332332 * @param codeView The code view
333333 * @param position 1-indexed position
334- * @param options Code-host specific implementations of DOM retrieval functions
334+ * @param domOptions Code-host specific implementations of DOM retrieval functions
335335 * @param part If the code view is a diff view, the part of the diff that the position refers to
336336 */
337337export const getTokenAtPosition = (
338338 codeView : HTMLElement ,
339- position : Position ,
340- options : DOMFunctions ,
339+ { line , character } : Position ,
340+ { getCodeElementFromLineNumber , getDiffCodePart } : DOMFunctions ,
341341 part ?: DiffPart
342342) : HTMLElement | undefined => {
343- const codeCell = options . getCodeElementFromLineNumber ( codeView , position . line , part )
344- if ( ! codeCell ) {
343+ const codeElement = getCodeElementFromLineNumber ( codeView , line , part )
344+ if ( ! codeElement ) {
345345 return undefined
346346 }
347-
348- return findElementWithOffset ( codeCell , position . character )
347+ // On diff pages, account for the +/- indicator
348+ if ( getDiffCodePart ) {
349+ character ++
350+ }
351+ return findElementWithOffset ( codeElement , character )
349352}
You can’t perform that action at this time.
0 commit comments