commentAnchorIndexAt method

int? commentAnchorIndexAt(
  1. int renderLine, {
  2. DiffCommentSide? side,
})

Returns the index of the comment anchor occupying renderLine.

Implementation

int? commentAnchorIndexAt(int renderLine, {DiffCommentSide? side}) {
  if (commentAnchors.isEmpty) return null;
  int? fallback;
  for (var index = 0; index < commentAnchors.length; index++) {
    final anchor = commentAnchors[index];
    if (renderLine < anchor.renderLine) break;
    if (renderLine >= anchor.renderLineEnd) continue;
    fallback ??= index;
    if (side == null || anchor.side == side) return index;
  }
  return fallback;
}