mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Set max value for progress task properly
Also clamp the task value if it's greater than the max value. Closes #163
This commit is contained in:

committed by
Patrik Svensson

parent
acf01e056f
commit
63abcc92ba
@ -167,7 +167,7 @@ namespace Spectre.Console
|
||||
|
||||
if (maxValue != null)
|
||||
{
|
||||
_maxValue += maxValue.Value;
|
||||
_maxValue = maxValue.Value;
|
||||
}
|
||||
|
||||
if (increment != null)
|
||||
@ -175,6 +175,12 @@ namespace Spectre.Console
|
||||
Value += increment.Value;
|
||||
}
|
||||
|
||||
// Need to cap the max value?
|
||||
if (Value > _maxValue)
|
||||
{
|
||||
Value = _maxValue;
|
||||
}
|
||||
|
||||
var timestamp = DateTime.Now;
|
||||
var threshold = timestamp - TimeSpan.FromSeconds(30);
|
||||
|
||||
|
Reference in New Issue
Block a user