commentAnchorAt method

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

Returns the comment anchor occupying renderLine, optionally preferring the requested side when multiple anchors share the same rendered row.

Implementation

DiffCommentAnchor? commentAnchorAt(int renderLine, {DiffCommentSide? side}) {
  if (commentAnchors.isEmpty) return null;
  DiffCommentAnchor? fallback;
  for (final anchor in commentAnchors) {
    if (renderLine < anchor.renderLine) break;
    if (renderLine >= anchor.renderLineEnd) continue;
    fallback ??= anchor;
    if (side == null || anchor.side == side) return anchor;
  }
  return fallback;
}