anchorIn method

Resolves a source key in layout, including left context in unified view.

Only a known context counterpart may supply geometry. The source key itself remains unchanged; unrelated same-number lines are never used.

Implementation

DiffCommentAnchor? anchorIn(DiffLayout layout, DiffCommentLineKey key) {
  if (!contains(key)) return null;
  final exact = layout.anchorFor(key);
  if (exact != null) return exact;
  final other = counterpart(key);
  final anchor = other == null ? null : layout.anchorFor(other);
  if (anchor == null) return null;
  return DiffCommentAnchor(
    path: key.path,
    line: key.line,
    side: key.side,
    kind: anchor.kind,
    renderLine: anchor.renderLine,
    renderLineEnd: anchor.renderLineEnd,
    content: anchor.content,
  );
}