Skip to content

Conversation

@jeppevammenkristensen
Copy link
Contributor

I ran into an issue where intialized and added Rows with no child renderables, you got an exception when tried to render it.

System.InvalidOperationException: Sequence contains no elements at System.Linq.ThrowHelper.ThrowNoElementsException() at System.Linq.Enumerable.MinInteger[TSource,TResult](IEnumerable1 source, Func2 selector) at System.Linq.Enumerable.Min[TSource](IEnumerable1 source, Func2 selector) at Spectre.Console.Rows.Measure(RenderOptions options, Int32 maxWidth) in /_/src/Spectre.Console/Widgets/Rows.cs:line 41 at Spectre.Console.Rendering.Renderable.Spectre.Console.Rendering.IRenderable.Measure(RenderOptions options, Int32 maxWidth) in /_/src/Spectre.Console/Rendering/Renderable.cs:line 12

The error occured because we call the Min extension method, that will throw an exception if the IEnumerable input is empty.

In this small fix we check to ensure if measurements is empty, and in that case return a mesurement with min and max set to 0.

@jeppevammenkristensen
Copy link
Contributor Author

@microsoft-github-policy-service agree

Copy link
Contributor

@patriksvensson patriksvensson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants