mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 21:38:16 +08:00

committed by
Patrik Svensson

parent
fa85216554
commit
2dd0eb9f74
@ -17,6 +17,11 @@ namespace Spectre.Console.Internal
|
||||
|
||||
public static string NormalizeLineEndings(this string text, bool native = false)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var normalized = text?.Replace("\r\n", "\n")
|
||||
?.Replace("\r", string.Empty);
|
||||
|
||||
|
@ -14,7 +14,7 @@ namespace Spectre.Console.Internal
|
||||
{
|
||||
ratios = ratios.Zip(maximums, (a, b) => (ratio: a, max: b)).Select(a => a.max > 0 ? a.ratio : 0).ToList();
|
||||
var totalRatio = ratios.Sum();
|
||||
if (totalRatio == 0)
|
||||
if (totalRatio <= 0)
|
||||
{
|
||||
return values;
|
||||
}
|
||||
@ -24,9 +24,9 @@ namespace Spectre.Console.Internal
|
||||
|
||||
foreach (var (ratio, maximum, value) in ratios.Zip(maximums, values))
|
||||
{
|
||||
if (ratio > 0 && totalRatio > 0)
|
||||
if (ratio != 0 && totalRatio > 0)
|
||||
{
|
||||
var distributed = (int)Math.Min(maximum, Math.Round(ratio * totalRemaining / (double)totalRatio));
|
||||
var distributed = (int)Math.Min(maximum, Math.Round((double)(ratio * totalRemaining / totalRatio)));
|
||||
result.Add(value - distributed);
|
||||
totalRemaining -= distributed;
|
||||
totalRatio -= ratio;
|
||||
|
Reference in New Issue
Block a user