From 13ba533fc41ee61a8021c90066c013b11fd313df Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Wed, 18 Nov 2020 07:18:12 -0600 Subject: [PATCH] helps table columns align a little bit better (#2753) * helps table columns align a little bit better * no change to push CI to work again. --- crates/nu-table/src/wrap.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/nu-table/src/wrap.rs b/crates/nu-table/src/wrap.rs index 6c147050e..c4803af90 100644 --- a/crates/nu-table/src/wrap.rs +++ b/crates/nu-table/src/wrap.rs @@ -57,7 +57,15 @@ pub fn split_sublines(input: &str) -> Vec> { line.split_terminator(' ') .map(|x| Subline { subline: x, - width: UnicodeWidthStr::width(x), + width: { + // We've tried UnicodeWidthStr::width(x), UnicodeSegmentation::graphemes(x, true).count() + // and x.chars().count() with all types of combinations. Currently, it appears that + // getting the max of char count and unicode width seems to produce the best layout. + // However, it's not perfect. + let c = x.chars().count(); + let u = UnicodeWidthStr::width(x); + std::cmp::max(c, u) + }, }) .collect::>() })