Skip to main content

Module: processTargets/modifiers/surroundingPair/findSurroundingPairCore

Functions

findSurroundingPairCore

findSurroundingPairCore(scopeType, delimiterOccurrences, acceptableDelimiters, selectionOffsets, bailOnUnmatchedAdjacent?): SurroundingPairOffsets | null

This function implements the core high-level surrounding pair algorithm shared by both the parse tree and textual implementations.

We first look for any delimiter pair where one of the delimiters itself contains our selection, for example if the user refers to a mark which is a delimiter token, or if the user's cursor is right next to a delimiter.

If we don't find a delimiter pair that way, we instead look for the smallest delimiter pair that contains the selection.

Parameters

NameTypeDefault valueDescription
scopeTypeSurroundingPairScopeTypeundefined-
delimiterOccurrencesPossibleDelimiterOccurrence[]undefinedA list of delimiter occurrences. Expected to be sorted by offsets
acceptableDelimitersSimpleSurroundingPairName[]undefinedA list of names of acceptable delimiters to look for
selectionOffsetsOffsetsundefinedThe offsets of the selection
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

Defined in

processTargets/modifiers/surroundingPair/findSurroundingPairCore.ts:35