extend method

  1. @override
BufferRangeBlock extend(
  1. CellOffset position
)
override

Returns the smallest range that contains both this range and the given position.

Implementation

@override
BufferRangeBlock extend(CellOffset position) {
  // If the position is within the block, there is nothing to do.
  if (contains(position)) {
    return this;
  }
  // Otherwise normalize the block and push the borders outside up to
  // the position to which the block has to extended.
  final normal = normalized;
  final extendBegin = CellOffset(
    min(normal.begin.x, position.x),
    min(normal.begin.y, position.y),
  );
  final extendEnd = CellOffset(
    max(normal.end.x, position.x),
    max(normal.end.y, position.y),
  );
  return BufferRangeBlock(extendBegin, extendEnd);
}