diff --git a/.changeset/clean-rows-plan.md b/.changeset/clean-rows-plan.md new file mode 100644 index 000000000..a845151cc --- /dev/null +++ b/.changeset/clean-rows-plan.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/hunk/src/ui/components/ui-components.test.tsx b/packages/hunk/src/ui/components/ui-components.test.tsx index cce6bce78..8730bba37 100644 --- a/packages/hunk/src/ui/components/ui-components.test.tsx +++ b/packages/hunk/src/ui/components/ui-components.test.tsx @@ -41,6 +41,7 @@ const { DiffSectionBody } = await import("../diff/DiffSectionBody"); const { measurePlannedRenderedRowHeight, measureRenderedRowHeight } = await import("../diff/codeRowLayout"); const { DiffRowView } = await import("../diff/DiffRowView"); +const { RawDiffRowView } = await import("../diff/RawDiffRowView"); function createTestDiffFile( id: string, @@ -658,7 +659,7 @@ describe("UI components", () => { const theme = resolveTheme("github-dark-default", null); const startUserNote = mock(() => undefined); const setup = await testRender( - { }; const renderRow = (showAddNoteBadge: boolean) => captureFrame( - { test("DiffRowView fills the reserved wrapped add-note column with row background", async () => { const theme = resolveTheme("github-dark-default", null); const setup = await testRender( - { test("DiffRowView keeps metadata row background within the measured row width", async () => { const theme = resolveTheme("github-dark-default", null); const setup = await testRender( - { for (const wrapLines of [false, true]) { const setup = await testRender( - { }; const measuredHeight = measureRenderedRowHeight(row, 4, 1, false, true, true, theme); const setup = await testRender( - { }; const measuredHeight = measureRenderedRowHeight(row, 4, 1, false, true, true, theme); const setup = await testRender( - = { }; /** Render common DiffRowView props while varying paint-sensitive inputs. */ -function codeRowView(row: DiffRow, options: Partial[0]> = {}) { +function codeRowView(row: DiffRow, options: Partial[0]> = {}) { const theme = options.theme ?? resolveTheme("github-dark-default", null); return ( - void; onStartUserNoteAtHunk?: (hunkIndex: number, target?: UserNoteLineTarget) => void; @@ -46,7 +41,6 @@ export interface DiffRowViewProps { */ export const DiffRowView = memo(function DiffRowViewComponent({ plannedRow, - row, width, lineNumberDigits, showLineNumbers, @@ -59,26 +53,15 @@ export const DiffRowView = memo(function DiffRowViewComponent({ copySelectedSide, cursorHighlight, lineHighlights, - anchorId, - noteGuideSide, showAddNoteBadge, onHoverRow, onStartUserNoteAtHunk, onToggleGap, }: DiffRowViewProps) { - const resolvedPlannedRow = - plannedRow ?? (row ? legacyPlannedDiffRow(row, anchorId, noteGuideSide) : undefined); - if (!resolvedPlannedRow) { - return null; - } - - if ( - resolvedPlannedRow.row.type === "collapsed" || - resolvedPlannedRow.row.type === "hunk-header" - ) { + if (plannedRow.row.type === "collapsed" || plannedRow.row.type === "hunk-header") { return ( { + row: DiffRow; + anchorId?: string; + noteGuideSide?: "old" | "new"; +} + +/** Wrap a raw diff row in the planned envelope required by the mounted row view. */ +export const RawDiffRowView = memo(function RawDiffRowViewComponent({ + row, + anchorId, + noteGuideSide, + ...viewProps +}: RawDiffRowViewProps) { + return ( + + ); +}); diff --git a/packages/hunk/src/ui/lib/extensionCurrentLine.tsx b/packages/hunk/src/ui/lib/extensionCurrentLine.tsx index b9e62cf8f..bf73db650 100644 --- a/packages/hunk/src/ui/lib/extensionCurrentLine.tsx +++ b/packages/hunk/src/ui/lib/extensionCurrentLine.tsx @@ -1,6 +1,6 @@ import type { ExtensionCurrentLinePaint } from "../../extension-api/types"; import type { DiffRow, SplitLineCell, StackLineCell } from "../diff/diffRows"; -import { DiffRowView } from "../diff/DiffRowView"; +import { RawDiffRowView } from "../diff/RawDiffRowView"; import type { DiffSectionRowPlan } from "../diff/diffSectionRowPlan"; import type { LineCursor } from "./lineCursors"; import type { AppTheme } from "../themes"; @@ -104,7 +104,7 @@ export function createExtensionCurrentLinePaint({ line: cursor.target.line, render(side: "old" | "new", width: number) { return ( -