Skip to main content

Module: processTargets/modifiers/surroundingPair/findDelimiterPairAdjacentToSelection

Functions

findDelimiterPairAdjacentToSelection

findDelimiterPairAdjacentToSelection(initialIndex, delimiterOccurrences, selectionOffsets, scopeType, bailOnUnmatchedAdjacent?): SurroundingPairOffsets | null

Looks for a surrounding pair where one of its delimiters contains the entire selection.

Parameters

NameTypeDefault valueDescription
initialIndexnumberundefinedThe index of the first delimiter to try within the delimiter occurrences list. Expected to be the index of the first delimiter whose end offset is greater than or equal to the end offset of the selection.
delimiterOccurrencesPossibleDelimiterOccurrence[]undefinedA list of delimiter occurrences. Expected to be sorted by offsets
selectionOffsetsOffsetsundefinedThe offsets of the selection
scopeTypeSurroundingPairScopeTypeundefined-
bailOnUnmatchedAdjacentbooleanfalseIf true, immediately return null if we find an adjacent delimiter that we can't find a match for. This variable will be true if the current iteration can't see the full document. In that case, we'd like to fail and let a subsequent pass try again in case the matching delimiter is outside the range we're looking.

Returns

SurroundingPairOffsets | null

The offsets of a surrounding pair, one of whose delimiters is adjacent to or containing the selection. Returns null if such a pair can't be found in the given list of delimiter occurrences.

Defined in

processTargets/modifiers/surroundingPair/findDelimiterPairAdjacentToSelection.ts:29