text_table.rs: fix max column width when displaying without header

This commit is contained in:
Dietmar Maurer 2020-02-28 10:05:59 +01:00
parent a5083b9028
commit 9d9ab22128

View File

@ -444,7 +444,7 @@ fn format_table<W: Write>(
let right_align = right_align.unwrap_or(is_numeric);
let mut max_width = header.chars().count();
let mut max_width = if options.noheader || options.noborder { 0 } else { header.chars().count() };
column_names.push(header);
@ -586,8 +586,8 @@ fn format_object<W: Write>(
const NAME_TITLE: &str = "Name";
const VALUE_TITLE: &str = "Value";
let mut max_name_width = NAME_TITLE.len();
let mut max_value_width = VALUE_TITLE.len();
let mut max_name_width = if options.noheader || options.noborder { 0 } else { NAME_TITLE.len() };
let mut max_value_width = if options.noheader || options.noborder { 0 } else { VALUE_TITLE.len() };
let column_names = vec![NAME_TITLE.to_string(), VALUE_TITLE.to_string()];