Adding test and update render to fix issue with rendering separator when headers are hidden fixing issue 1391.

This commit is contained in:
BlazeFace 2024-04-07 09:19:43 -07:00 committed by Patrik Svensson
parent eb38f76a6a
commit ff7282ecb8
3 changed files with 32 additions and 2 deletions

View File

@ -150,9 +150,9 @@ internal static class TableRenderer
result.Add(Segment.LineBreak);
}
// Show row separator?
// Show row separator, if headers are hidden show separator after the first row
if (context.Border.SupportsRowSeparator && context.ShowRowSeparators
&& !isFirstRow && !isLastRow)
&& (!isFirstRow || (isFirstRow && !context.ShowHeaders)) && !isLastRow)
{
var hasVisibleFootes = context is { ShowFooters: true, HasFooters: true };
var isNextLastLine = index == context.Rows.Count - 2;

View File

@ -0,0 +1,7 @@
┌────────┬────────┐
│ Qux │ Corgi │
├────────┼────────┤
│ Waldo │ Grault │
├────────┼────────┤
│ Garply │ Fred │
└────────┴────────┘

View File

@ -159,6 +159,29 @@ public sealed class TableTests
return Verifier.Verify(console.Output);
}
[Fact]
[Expectation("Render_Row_Separators_No_Header")]
public Task Should_Render_Table_With_Row_Separators_No_Header_Correctly()
{
// Given
var console = new TestConsole();
var table = new Table();
table.ShowRowSeparators();
table.HideHeaders();
table.AddColumns("Foo", "Bar");
table.AddRow("Qux", "Corgi");
table.AddRow("Waldo", "Grault");
table.AddRow("Garply", "Fred");
// When
console.Write(table);
// Then
return Verifier.Verify(console.Output);
}
[Fact]
[Expectation("Render_EA_Character")]
public Task Should_Render_Table_With_EA_Character_Correctly()