rich icon indicating copy to clipboard operation
rich copied to clipboard

Fix _get_padding_width() to respect pad_edge setting

Open MirrorDNA-Reflection-Protocol opened this issue 2 months ago • 0 comments

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