Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing #1391 Missing Separator When Headers are Hidden #1513

Merged
merged 1 commit into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Spectre.Console/Widgets/Table/TableRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ public static List<Segment> Render(TableRendererContext context, List<int> colum
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
┌────────┬────────┐
│ Qux │ Corgi │
├────────┼────────┤
│ Waldo │ Grault │
├────────┼────────┤
│ Garply │ Fred │
└────────┴────────┘
23 changes: 23 additions & 0 deletions test/Spectre.Console.Tests/Unit/Widgets/Table/TableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,29 @@ public Task Should_Render_Table_With_Row_Separators_Correctly()
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()
Expand Down