Skip to content

feat(table): add WithColumnMinWidths to set minimum column widths - #809

Merged
MarvinJWendt merged 1 commit into
pterm:masterfrom
ChrisJr404:feat/table-column-min-widths
Oct 10, 2026
Merged

MarvinJWendt merged 1 commit into
pterm:masterfrom
ChrisJr404:feat/table-column-min-widths

Conversation

@ChrisJr404

Copy link
Copy Markdown
Contributor

Fixes #224.

The table printer always sizes each column to its widest cell, so when you print a few tables one after another they almost never line up. This adds a WithColumnMinWidths option that sets a minimum display width per column. A column still grows to fit its content, it just never renders narrower than the minimum you give it, so handing the same minimums to several tables keeps their columns aligned.

Nothing changes when the option isn't set: an empty list is ignored, and a minimum below a column's natural content width has no effect. Widths line up with columns from the left, and any extra entries past the last column are ignored.

I added tests for the widening, the no-shrink guarantee, the align-two-tables use case and the out-of-range case, a snapshot, and a small _examples/table/column-min-widths demo.

TablePrinter sizes every column to its widest cell, so two tables printed
one after another rarely share a layout. WithColumnMinWidths sets a minimum
display width per column; a column still grows to fit its content but is
never rendered narrower than its minimum, so giving several tables the same
minimums lines their columns up.

Fixes pterm#224
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.27%. Comparing base (bacb2fc) to head (606a994).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #809      +/-   ##
==========================================
+ Coverage   92.21%   92.27%   +0.05%     
==========================================
  Files          66       66              
  Lines        4318     4324       +6     
==========================================
+ Hits         3982     3990       +8     
+ Misses        244      243       -1     
+ Partials       92       91       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MarvinJWendt
MarvinJWendt merged commit 1ee94dc into pterm:master Oct 10, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set Table size

2 participants