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
Name | Type | Default value | Description |
---|---|---|---|
initialIndex | number | undefined | The 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. |
delimiterOccurrences | PossibleDelimiterOccurrence [] | undefined | A list of delimiter occurrences. Expected to be sorted by offsets |
selectionOffsets | Offsets | undefined | The offsets of the selection |
scopeType | SurroundingPairScopeType | undefined | - |
bailOnUnmatchedAdjacent | boolean | false | If 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