fix(status): full-width tables + better diagnosis

This commit is contained in:
Peter Steinberger
2026-01-11 00:54:19 +01:00
parent f3882671c9
commit 5fa3ac1e01
9 changed files with 1063 additions and 885 deletions

View File

@@ -196,6 +196,39 @@ export function renderTable(opts: RenderTableOptions): string {
shrink(nonFlexOrder, absoluteMinWidths);
}
// If we have room and any flex columns, expand them to fill the available width.
// This keeps tables from looking "clipped" and reduces wrapping in wide terminals.
if (maxWidth) {
const sepCount = columns.length + 1;
const currentTotal = widths.reduce((a, b) => a + b, 0) + sepCount;
let extra = maxWidth - currentTotal;
if (extra > 0) {
const flexCols = columns
.map((c, i) => ({ c, i }))
.filter(({ c }) => Boolean(c.flex))
.map(({ i }) => i);
if (flexCols.length > 0) {
const caps = columns.map((c) =>
typeof c.maxWidth === "number" && c.maxWidth > 0
? Math.floor(c.maxWidth)
: Number.POSITIVE_INFINITY,
);
while (extra > 0) {
let progressed = false;
for (const i of flexCols) {
if ((widths[i] ?? 0) >= (caps[i] ?? Number.POSITIVE_INFINITY))
continue;
widths[i] = (widths[i] ?? 0) + 1;
extra -= 1;
progressed = true;
if (extra <= 0) break;
}
if (!progressed) break;
}
}
}
}
const box =
border === "ascii"
? {