1import type { NativeReviewDiffRow } from "../../diffs/nativeReviewDiffSurface";
2
3export type GuideDiffFocus = {
4 readonly side: "old" | "new";
5 readonly start: number;
6 readonly end: number;
7};
8
9/** Match original diff coordinates, including deletions and renamed files. */
10export function guideFocusedRows(
11 rows: readonly NativeReviewDiffRow[],
12 fileId: string | undefined,
13 focus: GuideDiffFocus | undefined,
14) {
15 if (!fileId || !focus) return [];
16 return rows.filter((row) => {
17 const line = focus.side === "old" ? row.oldLineNumber : row.newLineNumber;
18 return (
19 row.fileId === fileId &&
20 row.kind === "line" &&
21 line != null &&
22 line >= focus.start &&
23 line <= focus.end
24 );
25 });
26}