spectreconsole / spectre.console

A .NET library that makes it easier to create beautiful console applications.
https://spectreconsole.net
MIT License
8.93k stars 454 forks source link

Table line separators not showing for the first line when table headers are hidden #1391

Closed MoaidHathot closed 2 months ago

MoaidHathot commented 7 months ago

Information

Describe the bug When table headers are hidden, the first row separator is not drawn.

To Reproduce

var table = new Table();

table.AddColumn("First");
table.AddColumn("Second");

table.AddRow("1", "2");
table.AddRow("3", "4");
table.AddRow("5", "6");

table.ShowRowSeparators = true;
table.HideHeaders();

AnsiConsole.Write(table);

Expected behavior The first row separator should be visible even if table headers are hidden

Screenshots image

BlazeFace commented 3 months ago

Hello! I'm proposing a fix for this issue, [Commit c63b842 ](https://github.com/BlazeFace/spectre.console/commit/ . The edge case causing this is that the code assumes that headers are shown and does not render the first separator, the fix is to check if headers are hidden and if so render the separator! Let me know if I need to make any other changes as this is my first contribution @patriksvensson . Also can go ahead and make a PR but wanted to get confirmation first!

https://github.com/BlazeFace/spectre.console/blob/c63b842645f116a26bf6c45a69a94da15c0a866b/src/Spectre.Console/Widgets/Table/TableRenderer.cs#L154

BlazeFace commented 2 months ago

@FrankRay78 I think I have a pretty complete solution for this, should I go ahead and make a PR?

FrankRay78 commented 2 months ago

By all means @BlazeFace, please do. I normally maintain the CLI subsystem, but I can review/merge all PR's. I'll use this as an opportunity to upskill myself on the table widget.