From d1c21ae7b4e9f54d775584268d416f95800be37f Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Tue, 12 May 2020 10:24:42 -0400 Subject: [PATCH] fix: TableBuilder no longer draws redundant separators --- ICD.Common.Utils/TableBuilder.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ICD.Common.Utils/TableBuilder.cs b/ICD.Common.Utils/TableBuilder.cs index b2950d9..5d80f8a 100644 --- a/ICD.Common.Utils/TableBuilder.cs +++ b/ICD.Common.Utils/TableBuilder.cs @@ -182,12 +182,20 @@ namespace ICD.Common.Utils AppendRow(sb, m_Columns, columnWidths); AppendSeparator(sb, columnWidths); - foreach (string[] row in m_Rows) + string[] previousRow = null; + + for (int index = 0; index < m_Rows.Count; index++) { - if (row == null) - AppendSeparator(sb, columnWidths); - else + string[] row = m_Rows[index]; + + // Data row + if (row != null) AppendRow(sb, row, columnWidths); + // Separator + else if (previousRow != null && index < m_Rows.Count - 1) + AppendSeparator(sb, columnWidths); + + previousRow = row; } AppendBottomSeparator(sb, columnWidths);