From e798a86690102370bd2b48faf2a86a77de27fa2f Mon Sep 17 00:00:00 2001 From: ydagosto Date: Fri, 14 Feb 2025 14:53:43 -0800 Subject: [PATCH] fix(rust): Ensure ASCII ellipsis fits in column width --- crates/polars-core/src/fmt.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/polars-core/src/fmt.rs b/crates/polars-core/src/fmt.rs index 7715746f4360..362994f42439 100644 --- a/crates/polars-core/src/fmt.rs +++ b/crates/polars-core/src/fmt.rs @@ -747,8 +747,12 @@ impl Display for DataFrame { str_truncate + ellipsis_len + padding, std::cmp::max(name_lengths[idx], *elem_len), ); - if mx <= min_col_width { + if (mx <= min_col_width) && !(max_n_rows > 0 && height > max_n_rows) { + // col width is less than min width + table is not truncated constraints.push(col_width_exact(mx)); + } else if mx <= min_col_width { + // col width is less than min width + table is truncated (w/ ellipsis) + constraints.push(col_width_bounds(mx, min_col_width)); } else { constraints.push(col_width_bounds(min_col_width, mx)); }