mirror of
https://github.com/nushell/nushell
synced 2024-12-27 21:43:09 +00:00
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
1 changed files with 9 additions and 1 deletions
|
@ -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<_>>()
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue