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

@@ -239,7 +239,7 @@ namespace Spectre.Console.Rendering
}
// Same style?
if (previous.Style.Equals(segment.Style))
if (previous.Style.Equals(segment.Style) && !previous.IsLineBreak)
{
previous = new Segment(previous.Text + segment.Text, previous.Style);
}
@@ -299,7 +299,15 @@ namespace Spectre.Console.Rendering
while (lengthLeft > 0)
{
var index = totalLength - lengthLeft;
// How many characters should we take?
var take = Math.Min(width, totalLength - index);
if (take == 0)
{
// This shouldn't really occur, but I don't like
// never ending loops if it does...
throw new InvalidOperationException("Text folding failed since 'take' was zero.");
}
result.Add(new Segment(segment.Text.Substring(index, take), segment.Style));
lengthLeft -= take;