From 1cdfe358c274f9340bab4aedb1f4a0672914aff6 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Tue, 27 Aug 2019 18:06:30 +1200 Subject: [PATCH] Fix the utf-8 width calculation --- src/format/table.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/format/table.rs b/src/format/table.rs index 78a2708971..37ed516686 100644 --- a/src/format/table.rs +++ b/src/format/table.rs @@ -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