Skip to content

Muti line text support#21

Merged
BrunoVT1992 merged 18 commits intomasterfrom
feature/multiLineText
Apr 6, 2026
Merged

Muti line text support#21
BrunoVT1992 merged 18 commits intomasterfrom
feature/multiLineText

Conversation

@BrunoVT1992
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds multi-line cell rendering support to ConsoleTable.Text so headers, rows, and footers can contain newline characters and render as multiple physical lines with correct column sizing.

Changes:

  • Updated table rendering logic to split cell content by line breaks and render multi-line rows/headers/footers.
  • Added an extensive test suite covering multi-line rendering, alignment, padding, CRLF/LF handling, and mixed row types.
  • Updated docs/examples and bumped package version + changelog entry for v2.2.0.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
ConsoleTable.Text/Table.cs Implements multi-line splitting, width calculation based on widest line, and multi-line rendering in CreateValueLine.
Tests/ConsoleTable.Text.Tests/TableTests.cs Adds multi-line behavior tests and helper for output line parsing.
README.md Documents multi-line support and updates Quick Start example/output.
ConsoleTable.Text.Examples/Program.cs Adds multi-line example and updates some sample rows to include newlines.
ConsoleTable.Text/ConsoleTable.Text.csproj Bumps package version to 2.2.0.
ConsoleTable.slnx Includes the new 2.2.0 changelog file in the solution items.
ChangeLogs/2.2.0-ChangeLog.md Adds v2.2.0 release notes with a multi-line usage example and output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 389 to 393
foreach (var row in table)
{
if (row == null || row.Length <= 0)
continue;

Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToTable() calls CleanupRow (which converts null/empty rows into a single-column row), but GetMaxCellWidths() skips null/empty rows entirely. If a table contains only an empty row (e.g., AddRow() with no values) and no headers/footers, maximumCellWidths can end up length 0 and CreateValueLine() will throw IndexOutOfRangeException when rendering the cleaned row. Consider applying CleanupRow inside GetMaxCellWidths() (and when determining the initial column count) so widths are computed for the same normalized rows that are rendered.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test validates empty table does not throw exception

Comment on lines 43 to 45
```csharp
using ConsoleTable.Text;

Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Quick Start snippet uses Environment.NewLine and List<string[]> later in the example, but only imports ConsoleTable.Text. To make the snippet compile in projects without implicit global usings, add using System; and using System.Collections.Generic; (or fully-qualify those types).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only an exanple

new string[] { "Alice Cooper", $"30{Environment.NewLine}1995", "New York" },
new string[] { "Bob", $"25{Environment.NewLine}2000", "Los Angeles" },
new string[] { "Charlie Brown", $"67{Environment.NewLine}1958", "Chicago" },
new string[] { "Gloria", $"40{Environment.NewLine}1985", $"Chicago{Environment.NewLine}Originally fron Bogota, Colombia" }
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the example string: "Originally fron Bogota, Colombia" should be "Originally from Bogota, Colombia".

Suggested change
new string[] { "Gloria", $"40{Environment.NewLine}1985", $"Chicago{Environment.NewLine}Originally fron Bogota, Colombia" }
new string[] { "Gloria", $"40{Environment.NewLine}1985", $"Chicago{Environment.NewLine}Originally from Bogota, Colombia" }

Copilot uses AI. Check for mistakes.
Cell content can contain newlines and the table will adjust row height accordingly, in headers, rows and footers.


```csharp
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changelog snippet uses Environment.NewLine and List<string[]>, but only imports ConsoleTable.Text. Consider adding using System; and using System.Collections.Generic; so the example compiles without relying on implicit global usings.

Suggested change
```csharp
```csharp
using System;
using System.Collections.Generic;

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +24
new string[] { "Charlie Brown", $"67{Environment.NewLine}1958", "Chicago" },
new string[] { "Gloria", $"40{Environment.NewLine}1985", $"Chicago{Environment.NewLine}Originally fron Bogota, Colombia" }
},
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the example string: "Originally fron Bogota, Colombia" should be "Originally from Bogota, Colombia".

Copilot uses AI. Check for mistakes.
Bruno Van Thournout and others added 6 commits April 5, 2026 15:39
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 389 to +396
foreach (var row in table)
{
if (row == null || row.Length <= 0)
continue;

for (int i = 0; i < row.Length; i++)
{
var maxWidth = row[i].Length + paddingCount;
var lines = GetCellLines(row[i]);
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetMaxCellWidths() skips rows that are null or have Length <= 0, but ToTable() later calls CleanupRow() which converts those rows into a 1-column row (new[] { " " }). If Rows contains only an empty/null row (e.g., AddRow() with no values or AddRow(null)), maximumCellWidths can end up length 0 and CreateValueLine() will throw IndexOutOfRangeException when it tries to access maximumCellWidths[0]. Normalize rows consistently when computing widths (e.g., apply CleanupRow() while building/iterating table, and ensure maximumColumns is at least 1 when any row exists after cleanup).

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +28
[Fact]
public void Empty()
{
var table = new Table();

var result = table.ToTable();

Assert.Equal(string.Empty, result);
}
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test method name Empty doesn’t follow the naming pattern used throughout this file (e.g., SetHeaders_Success, ToTable_...). Consider renaming it to something descriptive like ToTable_EmptyTable_ReturnsEmptyString to keep the suite consistent and self-explanatory.

Copilot uses AI. Check for mistakes.
- Simple and intuitive API
- Optimized for performance
- Support for varying column counts across rows (each row can have its own number of cells)
- Multi line support (cell content can contain newlines and the table will adjust row height accordingly) in headers, rows and footers
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo/wording: consider using the hyphenated form “Multi-line support” (and “multi-line” as an adjective) for standard English usage.

Suggested change
- Multi line support (cell content can contain newlines and the table will adjust row height accordingly) in headers, rows and footers
- Multi-line support (cell content can contain newlines and the table will adjust row height accordingly) in headers, rows and footers

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,53 @@
# V2.2.0

## Multi line support
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo/wording: use “Multi-line support” (hyphenated) in the section header for standard English usage (and match README phrasing).

Suggested change
## Multi line support
## Multi-line support

Copilot uses AI. Check for mistakes.
private static void WriteMultiLineTable()
{
Console.WriteLine();
Console.WriteLine("Multi line table:");
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor wording: consider changing the output label to “Multi-line table:” for consistency with the README/changelog phrasing.

Suggested change
Console.WriteLine("Multi line table:");
Console.WriteLine("Multi-line table:");

Copilot uses AI. Check for mistakes.
@BrunoVT1992 BrunoVT1992 requested a review from Copilot April 6, 2026 13:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@BrunoVT1992 BrunoVT1992 merged commit 6357abb into master Apr 6, 2026
2 checks passed
@BrunoVT1992 BrunoVT1992 deleted the feature/multiLineText branch April 6, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants