Repository navigation
feat(table): add WithColumnMinWidths to set minimum column widths - #809
Merged
MarvinJWendt merged 1 commit intoOct 10, 2026
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
WithColumnMinWidthsoption 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-widthsdemo.