forked from extern/nushell
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:
parent
6d60bab2fd
commit
13ba533fc4
@ -57,7 +57,15 @@ pub fn split_sublines(input: &str) -> Vec<Vec<Subline>> {
|
|||||||
line.split_terminator(' ')
|
line.split_terminator(' ')
|
||||||
.map(|x| Subline {
|
.map(|x| Subline {
|
||||||
subline: x,
|
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<_>>()
|
.collect::<Vec<_>>()
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user