mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 21:38:16 +08:00
Fixes TextPath rendering bugs (#1308)
* Do not emit line break when rendering * Don't be greedy when measuring. * Fix a condition that decides if the path fits in the allotted space. Closes #1307
This commit is contained in:
@ -74,7 +74,7 @@ public sealed class TextPath : IRenderable, IHasJustification
|
||||
|
||||
return new Measurement(
|
||||
Math.Min(length, maxWidth),
|
||||
Math.Max(length, maxWidth));
|
||||
Math.Min(length, maxWidth));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@ -119,9 +119,6 @@ public sealed class TextPath : IRenderable, IHasJustification
|
||||
// Align the result
|
||||
Aligner.Align(parts, Justification, maxWidth);
|
||||
|
||||
// Insert a line break
|
||||
parts.Add(Segment.LineBreak);
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
@ -134,7 +131,7 @@ public sealed class TextPath : IRenderable, IHasJustification
|
||||
}
|
||||
|
||||
// Will it fit as is?
|
||||
if (_parts.Sum(p => Cell.GetCellLength(p)) + (_parts.Length - 1) < maxWidth)
|
||||
if (_parts.Sum(Cell.GetCellLength) + (_parts.Length - 1) <= maxWidth)
|
||||
{
|
||||
return _parts;
|
||||
}
|
||||
@ -159,7 +156,7 @@ public sealed class TextPath : IRenderable, IHasJustification
|
||||
var queueWidth =
|
||||
rootLength // Root (if rooted)
|
||||
+ ellipsisLength // Ellipsis
|
||||
+ queue.Sum(p => Cell.GetCellLength(p)) // Middle
|
||||
+ queue.Sum(Cell.GetCellLength) // Middle
|
||||
+ Cell.GetCellLength(_parts.Last()) // Last
|
||||
+ queue.Count + separatorCount; // Separators
|
||||
|
||||
|
Reference in New Issue
Block a user