From 9d9ab221280f5a6aed4e8ecb7243a43a00e56812 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 28 Feb 2020 10:05:59 +0100 Subject: [PATCH] text_table.rs: fix max column width when displaying without header --- proxmox/src/api/cli/text_table.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proxmox/src/api/cli/text_table.rs b/proxmox/src/api/cli/text_table.rs index 14db9bc7..08f4e816 100644 --- a/proxmox/src/api/cli/text_table.rs +++ b/proxmox/src/api/cli/text_table.rs @@ -444,7 +444,7 @@ fn format_table( 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( 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()];