Add support for rendering exceptions

This commit is contained in:
Patrik Svensson
2020-10-03 02:08:31 +02:00
committed by Patrik Svensson
parent 971f9032ba
commit 3c3afe7439
35 changed files with 926 additions and 41 deletions

View File

@ -94,8 +94,15 @@ namespace Spectre.Console
// Split the child segments into lines.
var childSegments = ((IRenderable)child).Render(context, childWidth);
foreach (var line in Segment.SplitLines(childSegments, panelWidth))
foreach (var line in Segment.SplitLines(childSegments, childWidth))
{
if (line.Count == 1 && line[0].IsWhiteSpace)
{
// NOTE: This check might impact other things.
// Hopefully not, but there is a chance.
continue;
}
result.Add(new Segment(border.GetPart(BoxBorderPart.Left), borderStyle));
var content = new List<Segment>();

View File

@ -227,17 +227,10 @@ namespace Spectre.Console
throw new InvalidOperationException("Iterator returned empty segment.");
}
if (newLine && current.IsWhiteSpace && !current.IsLineBreak)
{
newLine = false;
continue;
}
newLine = false;
if (current.IsLineBreak)
{
line.Add(current);
lines.Add(line);
line = new SegmentLine();
newLine = true;

View File

@ -44,22 +44,26 @@ namespace Spectre.Console
/// <inheritdoc/>
protected override IEnumerable<Segment> Render(RenderContext context, int maxWidth)
{
var result = new List<Segment>();
foreach (var child in _children)
{
var segments = child.Render(context, maxWidth);
foreach (var (_, _, last, segment) in segments.Enumerate())
{
yield return segment;
result.Add(segment);
if (last)
{
if (!segment.IsLineBreak)
{
yield return Segment.LineBreak;
result.Add(Segment.LineBreak);
}
}
}
}
return result;
}
}
}

View File

@ -298,7 +298,6 @@ namespace Spectre.Console
var widths = width_ranges.Select(range => range.Max).ToList();
var tableWidth = widths.Sum();
if (tableWidth > maxWidth)
{
var wrappable = _columns.Select(c => !c.NoWrap).ToList();