mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 21:38:16 +08:00
ProgressTask.GetPercentage() returns 100 when max value is 0 (#1694)
This commit is contained in:
@ -224,6 +224,11 @@ public sealed class ProgressTask : IProgress<double>
|
||||
|
||||
private double GetPercentage()
|
||||
{
|
||||
if (MaxValue == 0)
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
var percentage = (Value / MaxValue) * 100;
|
||||
percentage = Math.Min(100, Math.Max(0, percentage));
|
||||
return percentage;
|
||||
|
Reference in New Issue
Block a user