diff --git a/packages/gittensory-engine/src/review/screenshot-table-gate.ts b/packages/gittensory-engine/src/review/screenshot-table-gate.ts index 60891c947..c4905b41d 100644 --- a/packages/gittensory-engine/src/review/screenshot-table-gate.ts +++ b/packages/gittensory-engine/src/review/screenshot-table-gate.ts @@ -211,6 +211,7 @@ export function extractTableRows(body: string | null | undefined): string[][] { rows.push(cells); j += 1; } + i = j - 1; } return rows; } diff --git a/src/review/screenshot-table-gate.ts b/src/review/screenshot-table-gate.ts index f55adbd37..b12323ecb 100644 --- a/src/review/screenshot-table-gate.ts +++ b/src/review/screenshot-table-gate.ts @@ -211,6 +211,7 @@ export function extractTableRows(body: string | null | undefined): string[][] { rows.push(cells); j += 1; } + i = j - 1; } return rows; } diff --git a/test/unit/screenshot-table-gate-engine.test.ts b/test/unit/screenshot-table-gate-engine.test.ts index 4591dcfef..767cb146d 100644 --- a/test/unit/screenshot-table-gate-engine.test.ts +++ b/test/unit/screenshot-table-gate-engine.test.ts @@ -6,6 +6,7 @@ import { DEFAULT_SCREENSHOT_TABLE_GATE, evaluateScreenshotTableGate, extractTableRowImageUrls, + extractTableRows, hasCommittedImageFile, hasImageBearingMarkdownTable, hasImageOutsideTable, @@ -322,6 +323,14 @@ describe("requiredScreenshotMatrixPairs (#4535)", () => { }); }); +describe("extractTableRows", () => { + it("extracts a crafted separator-only table once instead of duplicating overlapping regions", () => { + const body = Array.from({ length: 40 }, () => "| --- |").join("\n"); + + expect(extractTableRows(body)).toHaveLength(38); + }); +}); + describe("missingScreenshotMatrixPairs (#4535)", () => { const FULL_MATRIX_BODY = [ "| Viewport · Theme | Before | After |", diff --git a/test/unit/screenshot-table-gate.test.ts b/test/unit/screenshot-table-gate.test.ts index 8c7dead3d..1ac43a330 100644 --- a/test/unit/screenshot-table-gate.test.ts +++ b/test/unit/screenshot-table-gate.test.ts @@ -5,6 +5,7 @@ import { DEFAULT_SCREENSHOT_TABLE_GATE, evaluateScreenshotTableGate, extractTableRowImageUrls, + extractTableRows, hasCommittedImageFile, hasImageBearingMarkdownTable, hasImageOutsideTable, @@ -321,6 +322,14 @@ describe("requiredScreenshotMatrixPairs (#4535)", () => { }); }); +describe("extractTableRows", () => { + it("extracts a crafted separator-only table once instead of duplicating overlapping regions", () => { + const body = Array.from({ length: 40 }, () => "| --- |").join("\n"); + + expect(extractTableRows(body)).toHaveLength(38); + }); +}); + describe("missingScreenshotMatrixPairs (#4535)", () => { const FULL_MATRIX_BODY = [ "| Viewport · Theme | Before | After |",