Merge pull request #483 from jonathandturner/fix_width_calculation

Fix the utf-8 width calculation
This commit is contained in:
Jonathan Turner 2019-08-27 18:32:48 +12:00 committed by GitHub
commit 247a4417ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,13 +78,16 @@ impl TableView {
for head in 0..headers.len() {
let mut current_col_max = 0;
for row in 0..values.len() {
let value_length = entries[row][head].0.len();
if head > entries[row].len() && value_length > current_col_max {
let value_length = entries[row][head].0.chars().count();
if value_length > current_col_max {
current_col_max = value_length;
}
}
max_per_column.push(std::cmp::max(current_col_max, headers[head].len()));
max_per_column.push(std::cmp::max(
current_col_max,
headers[head].chars().count(),
));
}
// Different platforms want different amounts of buffer, not sure why