Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/ui/diff/plannedReviewRows.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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<number, number>;
hunkBounds: Map<number, PlannedHunkBounds>;
}
export type PlannedSectionGeometry = SectionGeometry<PlannedHunkBounds>;

/** Return whether this planned row should count toward a hunk's own visible extent. */
function rowContributesToHunkBounds(row: PlannedReviewRow) {
Expand Down
10 changes: 3 additions & 7 deletions src/ui/lib/diffSectionGeometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number, number>;
hunkBounds: Map<number, PlannedHunkBounds>;
export interface DiffSectionGeometry extends SectionGeometry<PlannedHunkBounds> {
rowBounds: DiffSectionRowBounds[];
rowBoundsByKey: Map<string, DiffSectionRowBounds>;
}
Expand Down
17 changes: 17 additions & 0 deletions src/ui/lib/diffSpatial.ts
Original file line number Diff line number Diff line change
@@ -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<THunkBounds extends VerticalBounds> {
bodyHeight: number;
hunkAnchorRows: Map<number, number>;
hunkBounds: Map<number, THunkBounds>;
}
Loading