Fix table --expand case with wrapping of emojie (#15948)

close #15940
This commit is contained in:
Maxim Zhiburt
2025-06-15 02:39:39 +03:00
committed by GitHub
parent 4c19242c0d
commit 091d14f085

View File

@ -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);