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.
This commit is contained in:
Darren Schroeder 2020-11-18 07:18:12 -06:00 committed by GitHub
parent 6d60bab2fd
commit 13ba533fc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,7 +57,15 @@ pub fn split_sublines(input: &str) -> Vec<Vec<Subline>> {
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::<Vec<_>>()
})