diff --git a/src/ui/diff/plannedReviewRows.ts b/src/ui/diff/plannedReviewRows.ts index 9bc09f7..5d8a985 100644 --- a/src/ui/diff/plannedReviewRows.ts +++ b/src/ui/diff/plannedReviewRows.ts @@ -1,5 +1,6 @@ import type { LayoutMode } from "../../core/types"; import { measureAgentInlineNoteHeight } from "../components/panes/AgentInlineNote"; +import type { SectionGeometry, VerticalBounds } from "../lib/diffSpatial"; import { reviewRowId } from "../lib/ids"; import type { PlannedReviewRow } from "./reviewRenderPlan"; @@ -15,19 +16,13 @@ export interface PlannedReviewRowLayoutOptions { * * The row ids let DiffPane upgrade from planned measurements to exact mounted measurements later. */ -export interface PlannedHunkBounds { - top: number; - height: number; +export interface PlannedHunkBounds extends VerticalBounds { startRowId: string; endRowId: string; } /** Aggregate geometry for one file section measured from planned review rows. */ -export interface PlannedSectionGeometry { - bodyHeight: number; - hunkAnchorRows: Map; - hunkBounds: Map; -} +export type PlannedSectionGeometry = SectionGeometry; /** Return whether this planned row should count toward a hunk's own visible extent. */ function rowContributesToHunkBounds(row: PlannedReviewRow) { diff --git a/src/ui/lib/diffSectionGeometry.ts b/src/ui/lib/diffSectionGeometry.ts index e46a4bd..17b7109 100644 --- a/src/ui/lib/diffSectionGeometry.ts +++ b/src/ui/lib/diffSectionGeometry.ts @@ -4,21 +4,17 @@ import { buildSplitRows, buildStackRows } from "../diff/pierre"; import { measureRenderedRowHeight, findMaxLineNumber } from "../diff/renderRows"; import type { PlannedHunkBounds } from "../diff/plannedReviewRows"; import { buildReviewRenderPlan, type PlannedReviewRow } from "../diff/reviewRenderPlan"; +import type { SectionGeometry, VerticalBounds } from "./diffSpatial"; import { reviewRowId } from "./ids"; import type { VisibleAgentNote } from "./agentAnnotations"; import type { AppTheme } from "../themes"; -export interface DiffSectionRowBounds { +export interface DiffSectionRowBounds extends VerticalBounds { key: string; - top: number; - height: number; } /** Cached placeholder sizing and hunk navigation geometry for one file section. */ -export interface DiffSectionGeometry { - bodyHeight: number; - hunkAnchorRows: Map; - hunkBounds: Map; +export interface DiffSectionGeometry extends SectionGeometry { rowBounds: DiffSectionRowBounds[]; rowBoundsByKey: Map; } diff --git a/src/ui/lib/diffSpatial.ts b/src/ui/lib/diffSpatial.ts new file mode 100644 index 0000000..8320487 --- /dev/null +++ b/src/ui/lib/diffSpatial.ts @@ -0,0 +1,17 @@ +/** One vertical extent measured in terminal rows within a single coordinate space. */ +export interface VerticalBounds { + top: number; + height: number; +} + +/** + * Shared geometry for one file section body. + * + * `bodyHeight` and every nested `top` value should use the same coordinate space, such as + * section-body-relative rows or whole-stream rows. + */ +export interface SectionGeometry { + bodyHeight: number; + hunkAnchorRows: Map; + hunkBounds: Map; +}