Skip to content

Commit 87a0e10

Browse files
committed
fix(issue-list): correct off-by-one in auto-compact height estimation
The last data row has no trailing separator (row separators are drawn between data rows only), so the real table height is 3N+3, not 3N+4. Adjust TABLE_LINE_OVERHEAD from 4 to 3.
1 parent f767957 commit 87a0e10

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/lib/formatters/human.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,15 @@ const TREND_MIN_TERM_WIDTH = 100;
396396
/** Lines per issue row in non-compact mode (2-line content + separator). */
397397
const LINES_PER_DEFAULT_ROW = 3;
398398

399-
/** Fixed line overhead: top border, header, header separator, bottom border. */
400-
const TABLE_LINE_OVERHEAD = 4;
399+
/**
400+
* Fixed line overhead for the rendered table.
401+
*
402+
* Top border (1) + header row (1) + header separator (1) + bottom border (1) = 4,
403+
* minus 1 because the last data row has no trailing separator (row separators
404+
* are drawn between data rows only: `r > 0 && r < allRows.length - 1`).
405+
* Net overhead = 3.
406+
*/
407+
const TABLE_LINE_OVERHEAD = 3;
401408

402409
/**
403410
* Determine whether auto-compact should activate based on terminal height.

test/lib/formatters/auto-compact.property.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import { DEFAULT_NUM_RUNS } from "../../model-based/helpers.js";
1414
/** Lines per non-compact row (2 content + 1 separator). */
1515
const LINES_PER_ROW = 3;
1616

17-
/** Fixed overhead: top border + header + header separator + bottom border. */
18-
const OVERHEAD = 4;
17+
/** Fixed overhead: top border + header + header sep + bottom border − 1 (no trailing row sep). */
18+
const OVERHEAD = 3;
1919

2020
/** Save original process.stdout.rows so we can restore it after each test. */
2121
let originalRows: number | undefined;

0 commit comments

Comments
 (0)