Skip to content

Conversation

@MirrorDNA-Reflection-Protocol

Summary

Fixes #3892

When pad_edge=False is 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 the pad_edge setting.

Root Cause

The _get_cells() method already correctly handles pad_edge=False by 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_edge check to _get_padding_width():

  • For the first column: set pad_left = 0 when pad_edge=False
  • For the last column: set pad_right = 0 when pad_edge=False

Testing

Added regression test test_pad_edge_false_with_fixed_width_columns that reproduces the exact scenario from the issue. All existing table tests continue to pass.

Before/After

Before (with pad_edge=False and fixed widths):

verb     noun     wh  
hello    world    oh  

After:

verb   noun   wh
hello  world  oh

Fixes Textualize#3892

When pad_edge=False, the _get_padding_width() method was still returning
the full padding width for edge columns, causing fixed-width columns to
be rendered wider than specified.

The fix adds the same pad_edge check to _get_padding_width() that already
exists in _get_cells(), zeroing out the left padding for the first column
and the right padding for the last column when pad_edge is False.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] rich.table.Table._get_padding_width() forgets to account for self.pad_edge

1 participant