mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-15 08:22:51 +08:00
Add fix to avoid exception on Rows with no children
This commit is contained in:
parent
d484e832f5
commit
e0ded712e8
@ -37,10 +37,15 @@ public sealed class Rows : Renderable, IExpandable
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var measurements = _children.Select(c => c.Measure(options, maxWidth));
|
var measurements = _children.Select(c => c.Measure(options, maxWidth)).ToArray();
|
||||||
return new Measurement(
|
if (measurements.Length > 0)
|
||||||
measurements.Min(c => c.Min),
|
{
|
||||||
measurements.Min(c => c.Max));
|
return new Measurement(
|
||||||
|
measurements.Min(c => c.Min),
|
||||||
|
measurements.Min(c => c.Max));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Measurement(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
┌─────────────┬─────┐
|
||||||
|
│ Foo │ Bar │
|
||||||
|
├─────────────┼─────┤
|
||||||
|
│ HELLO WORLD │ │
|
||||||
|
│ │ Qux │
|
||||||
|
└─────────────┴─────┘
|
@ -12,6 +12,9 @@
|
|||||||
<EmbeddedResource Include="Data\starwars.flf" />
|
<EmbeddedResource Include="Data\starwars.flf" />
|
||||||
<None Remove="Data\poison.flf" />
|
<None Remove="Data\poison.flf" />
|
||||||
<EmbeddedResource Include="Data\poison.flf" />
|
<EmbeddedResource Include="Data\poison.flf" />
|
||||||
|
<None Update="Expectations\Widgets\Rows\Render_Empty.Output.verified.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -50,6 +50,25 @@ public sealed class RowsTests
|
|||||||
return Verifier.Verify(console.Output);
|
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]
|
[Fact]
|
||||||
[Expectation("Render_Expanded_And_Nested")]
|
[Expectation("Render_Expanded_And_Nested")]
|
||||||
public Task Should_Render_Rows_Correctly_Inside_Other_Widget_When_Expanded()
|
public Task Should_Render_Rows_Correctly_Inside_Other_Widget_When_Expanded()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user