Fix _get_padding_width() to respect pad_edge setting #3909
+43
−0
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.
Summary
Fixes #3892
When
pad_edge=Falseis set on a Table with fixed-width columns, the first and last columns were being rendered wider than their specified width. This was because_get_padding_width()was returning the full padding width without accounting for thepad_edgesetting.Root Cause
The
_get_cells()method already correctly handlespad_edge=Falseby zeroing out padding for edge cells. However,_get_padding_width()(used in_measure_column()) did not apply the same logic, causing width calculations to include padding that wouldn't actually be rendered.Fix
Added the same
pad_edgecheck to_get_padding_width():pad_left = 0whenpad_edge=Falsepad_right = 0whenpad_edge=FalseTesting
Added regression test
test_pad_edge_false_with_fixed_width_columnsthat reproduces the exact scenario from the issue. All existing table tests continue to pass.Before/After
Before (with
pad_edge=Falseand fixed widths):After: