Do not draw tables that can't be drawn

This is a temporary fix for undrawable tables until we've
implemented a proper strategy. What this does is that it replaces
an undrawable table with an ellipsis (...). This should only
occur in either super big tables or deeply nested tables in a
console with a small buffer width.
This commit is contained in:
Patrik Svensson
2020-10-18 07:27:37 +02:00
committed by Patrik Svensson
parent a2f507e58f
commit bfffef630f
6 changed files with 155 additions and 22 deletions

View File

@@ -193,6 +193,12 @@ namespace Spectre.Console
private List<SegmentLine> SplitLines(RenderContext context, int maxWidth)
{
if (maxWidth <= 0)
{
// Nothing fits, so return an empty line.
return new List<SegmentLine>();
}
if (_lines.Max(x => x.CellWidth(context)) <= maxWidth)
{
return Clone();