Preserve line breaks

This commit is contained in:
Patrik Svensson
2020-08-10 11:35:01 +02:00
committed by Patrik Svensson
parent f4d1796e40
commit 22d4af4482
3 changed files with 21 additions and 3 deletions

View File

@ -136,7 +136,7 @@ namespace Spectre.Console
/// <inheritdoc/>
IEnumerable<Segment> IRenderable.Render(RenderContext context, int width)
{
if (string.IsNullOrWhiteSpace(_text))
if (string.IsNullOrEmpty(_text))
{
return Array.Empty<Segment>();
}
@ -192,7 +192,7 @@ namespace Spectre.Console
}
}
if (!last)
if (!last || line.Count == 0)
{
result.Add(Segment.LineBreak());
}
@ -214,7 +214,10 @@ namespace Spectre.Console
var index = segment.Text.IndexOf("\n", StringComparison.OrdinalIgnoreCase);
if (index == -1)
{
result.Add(segment);
if (!string.IsNullOrEmpty(segment.Text))
{
result.Add(segment);
}
}
else
{