findBlockStart method
Searches (backwards) the start of the block starting at a given position.
block
: specifies the block parameters: start, end, body.
The start of the block is stored in startOfBlock
. If null currentPosition
is taken.
startPosition
: defines the start of the search.
offsetBackward
: before starting the start position is moved this offset
in direction of text start.
Returns true: the block has been found.
Implementation
bool findBlockStart(Block block,
{Position? startOfBlock,
Position? startPosition,
int offsetBackward = 0}) {
tempPosition.clone(startPosition ?? currentPosition);
if (offsetBackward != 0) {
tempPosition.backward(offsetBackward);
}
var rc = false;
if (currentRegion.contains(tempPosition)) {
tempPosition.clone(startPosition ?? currentPosition);
if (currentRegion.contains(tempPosition)) {
rc = traverseBlock(block.reverseEntries, tempPosition.line, -1,
currentRegion.start.line - 1, startPosition ?? currentPosition);
}
}
return rc;
}