Repository: spectreconsole/spectre.console

Issue:
Rows sizing is inconsistent
**Information**
 - OS: Windows
 - Version: 0.46
 - Terminal: Powershell, Windows Rider Integrated Terminal

**Describe the bug**

Sizing of `Panel` is confusing and buggy:

- There's no way to make the panel fit its contents. Instead, it expands the full width of the terminal (which looks ugly)
- Depending on the content I put in it, the size behavior changes.

**To Reproduce**

See MCVE:

```cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Spectre.Console;
using Spectre.Console.Cli;
using Spectre.Console.Rendering;

namespace ConsoleApp1;

public enum SupportedServices { Radarr, Sonarr }

public record MyConfig(string InstanceName, SupportedServices Service);

public class ConfigLocalLister : Command<ConfigLocalLister.CliSettings>
{
    public class CliSettings : CommandSettings
    {

    }

    private readonly IAnsiConsole _console;

    public ConfigLocalLister(IAnsiConsole console)
    {
        _console = console;
    }

    private void List()
    {
        var appDataDir = @"C:\appDataDir";
        var tree = new Tree(appDataDir);

        var configsDict = new Dictionary<string, MyConfig[]>
        {
            {
                "radarr.yml", new[]
                {
                    new MyConfig("instance1", SupportedServices.Radarr),
                }
            },
            {
                "sonarr.yml", new[]
                {
                    new MyConfig("instance2", SupportedServices.Sonarr),
                    new MyConfig("instance3", SupportedServices.Sonarr),
                }
            },
            {
                "both.yml", new[]
                {
                    new MyConfig("instance4", SupportedServices.Radarr),
                    new MyConfig("instance5", SupportedServices.Radarr),
                    new MyConfig("instance6", SupportedServices.Sonarr),
                    new MyConfig("instance7", SupportedServices.Sonarr),
                }
            },
        };

        foreach (var configPath in configsDict.Keys)
        {
            var configs = configsDict[configPath];

            var rows = new List<IRenderable>();
            BuildInstanceTree(rows, configs, SupportedServices.Radarr);
            BuildInstanceTree(rows, configs, SupportedServices.Sonarr);

            if (!rows.Any())
            {
                rows.Add(new Markup("([red]Empty[/])"));
            }

            var rowsWidget = new Rows(rows);
            var panel = new Panel(rowsWidget)
                .Header(configPath);

            tree.AddNode(panel);
        }

        _console.WriteLine();
        _console.Write(tree);
    }

    private static void BuildInstanceTree(
        ICollection<IRenderable> rows,
        MyConfig[] registry,
        SupportedServices service)
    {
        var configs = registry.Where(x => x.Service == service).ToList();
        if (!configs.Any())
        {
            return;
        }

        var tree = new Tree(service.ToString());
        tree.AddNodes(configs.Select(c =>
            Markup.FromInterpolated($"[blue]{c.InstanceName}[/]")));

        if (rows.Any())
        {
            // This causes the size of the panel to adjust to the length of this line
            rows.Add(new Text("---------------------------"));
        }

        rows.Add(tree);
    }

    public override int Execute(CommandContext context, CliSettings settings)
    {
        List();
        return 0;
    }
}

public static class Program
{
    public static void Main(string[] args)
    {
        var app = new CommandApp();
        app.Configure(c =>
        {
            c.AddCommand<ConfigLocalLister>("list");
        });

        app.Run(args);
    }
}
```

**Expected behavior**

1. There should be a way to tell the panel to fit its contents
2. The third panel in the tree is sized inconsistently; the inconsistency is the bug but I don't know what the actual expected sizing behavior is.

**Screenshots**

![image](https://user-images.githubusercontent.com/1768054/222853351-81183c33-6818-44eb-a56a-09a81037c9f1.png)



Hints:

Patch:
diff --git a/src/Spectre.Console/Widgets/Rows.cs b/src/Spectre.Console/Widgets/Rows.cs
index 8e3e59576..91c963f03 100644
--- a/src/Spectre.Console/Widgets/Rows.cs
+++ b/src/Spectre.Console/Widgets/Rows.cs
@@ -41,8 +41,8 @@ protected override Measurement Measure(RenderOptions options, int maxWidth)
             if (measurements.Length > 0)
             {
                 return new Measurement(
-                    measurements.Min(c => c.Min),
-                    measurements.Min(c => c.Max));
+                    measurements.Max(c => c.Min),
+                    measurements.Max(c => c.Max));
             }
 
             return new Measurement(0, 0);


Test patch:
diff --git a/test/Spectre.Console.Tests/Expectations/Widgets/Rows/GH-1188-Rows.Output.verified.txt b/test/Spectre.Console.Tests/Expectations/Widgets/Rows/GH-1188-Rows.Output.verified.txt
new file mode 100644
index 000000000..ed5efe628
--- /dev/null
+++ b/test/Spectre.Console.Tests/Expectations/Widgets/Rows/GH-1188-Rows.Output.verified.txt
@@ -0,0 +1,5 @@
+﻿┌─────┐
+│ 1   │
+│ 22  │
+│ 333 │
+└─────┘
diff --git a/test/Spectre.Console.Tests/Unit/Widgets/RowsTests.cs b/test/Spectre.Console.Tests/Unit/Widgets/RowsTests.cs
index 9d95e64bf..6937d842f 100644
--- a/test/Spectre.Console.Tests/Unit/Widgets/RowsTests.cs
+++ b/test/Spectre.Console.Tests/Unit/Widgets/RowsTests.cs
@@ -4,6 +4,29 @@ namespace Spectre.Console.Tests.Unit;
 [ExpectationPath("Widgets/Rows")]
 public sealed class RowsTests
 {
+    [Fact]
+    [Expectation("GH-1188-Rows")]
+    [GitHubIssue("https://github.com/spectreconsole/spectre.console/issues/1188")]
+    public Task Should_Render_Rows_In_Panel_Without_Breaking_Lines()
+    {
+        // Given
+        var console = new TestConsole().Width(60);
+        var rows = new Rows(
+            new IRenderable[]
+            {
+                new Text("1"),
+                new Text("22"),
+                new Text("333"),
+            });
+        var panel = new Panel(rows);
+
+        // When
+        console.Write(panel);
+
+        // Then
+        return Verifier.Verify(console.Output);
+    }
+
     [Fact]
     [Expectation("Render")]
     public Task Should_Render_Rows()