Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

guideDiffFocus.ts

25 lines653 Bytes

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​
9export function guideFocusedRows(
10 rows: readonly NativeReviewDiffRow[],
11 fileId: string | undefined,
12 focus: GuideDiffFocus | undefined,
13) {
14 if (!fileId || !focus) return [];
15 return rows.filter((row) => {
16 const line = focus.side === "old" ? row.oldLineNumber : row.newLineNumber;
17 return (
18 row.fileId === fileId &&
19 row.kind === "line" &&
20 line != null &&
21 line >= focus.start &&
22 line <= focus.end
23 );
24 });