From 091d14f085ece78b4e05a29af4337b326d8fc029 Mon Sep 17 00:00:00 2001 From: Maxim Zhiburt Date: Sun, 15 Jun 2025 02:39:39 +0300 Subject: [PATCH] Fix table --expand case with wrapping of emojie (#15948) close #15940 --- crates/nu-table/src/types/expanded.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/nu-table/src/types/expanded.rs b/crates/nu-table/src/types/expanded.rs index f034a18c07..81897f251d 100644 --- a/crates/nu-table/src/types/expanded.rs +++ b/crates/nu-table/src/types/expanded.rs @@ -298,8 +298,18 @@ fn expand_list(input: &[Value], cfg: Cfg<'_>) -> TableResult { let inner_cfg = cfg_expand_reset_table(cfg.clone(), available); let cell = expand_entry_with_header(item, &header, inner_cfg); // TODO: optimize cause when we expand we alrready know the width (most of the time or all) - let value = NuTable::create(cell.text); - let value_width = value.width(); + let mut value = NuTable::create(cell.text); + let mut value_width = value.width(); + if value_width > available { + // NOTE: + // most likely it was emojie which we are not sure about what to do + // so we truncate it just in case + // + // most likely width is 1 + + value = NuTable::create(String::from("\u{FFFD}")); + value_width = 1; + } column_width = max(column_width, value_width);