Skip to content
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
13 changes: 9 additions & 4 deletions src/Spectre.Console/Widgets/Rows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ protected override Measurement Measure(RenderOptions options, int maxWidth)
}
else
{
var measurements = _children.Select(c => c.Measure(options, maxWidth));
return new Measurement(
measurements.Min(c => c.Min),
measurements.Min(c => c.Max));
var measurements = _children.Select(c => c.Measure(options, maxWidth)).ToArray();
if (measurements.Length > 0)
{
return new Measurement(
measurements.Min(c => c.Min),
measurements.Min(c => c.Max));
}

return new Measurement(0, 0);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
┌─────────────┬─────┐
│ Foo │ Bar │
├─────────────┼─────┤
│ HELLO WORLD │ │
│ │ Qux │
└─────────────┴─────┘
3 changes: 3 additions & 0 deletions test/Spectre.Console.Tests/Spectre.Console.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<EmbeddedResource Include="Data\starwars.flf" />
<None Remove="Data\poison.flf" />
<EmbeddedResource Include="Data\poison.flf" />
<None Update="Expectations\Widgets\Rows\Render_Empty.Output.verified.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
Expand Down
19 changes: 19 additions & 0 deletions test/Spectre.Console.Tests/Unit/Widgets/RowsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ public Task Should_Render_Rows_Correctly_Inside_Other_Widget()
return Verifier.Verify(console.Output);
}

[Fact]
[Expectation("Render_Empty")]
public Task Should_Not_Throw_Exception_On_Empty_Rows()
{
// Given
var console = new TestConsole().Width(60);
var table = new Table()
.AddColumns("Foo", "Bar")
.AddRow("HELLO WORLD")
.AddRow(
new Rows(), new Text("Qux"));

// When
console.Write(table);

// Then
return Verifier.Verify(console.Output);
}

[Fact]
[Expectation("Render_Expanded_And_Nested")]
public Task Should_Render_Rows_Correctly_Inside_Other_Widget_When_Expanded()
Expand Down