mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 20:39:40 -08:00
parent
d62c3d6e37
commit
4641146b1e
|
@ -43,13 +43,20 @@ func (b *batt) enabled() bool {
|
|||
}
|
||||
|
||||
displayError := b.props.getBool(DisplayError, false)
|
||||
if err != nil && !displayError {
|
||||
b.percentageText = "100%"
|
||||
if err != nil && displayError {
|
||||
b.percentageText = "BATT ERR"
|
||||
return true
|
||||
}
|
||||
if err != nil {
|
||||
b.percentageText = "BATT ERR"
|
||||
return true
|
||||
// On Windows, it sometimes errors when the battery is full.
|
||||
// This hack ensures we display a fully charged battery, even if
|
||||
// that state can be incorrect. It's better to "ignore" the error
|
||||
// than to not display the segment at all as that will confuse users.
|
||||
bt = &battery.Battery{
|
||||
Current: 100,
|
||||
Full: 100,
|
||||
State: battery.Full,
|
||||
}
|
||||
}
|
||||
batteryPercentage := bt.Current / bt.Full * 100
|
||||
batteryPercentage = math.Min(100, batteryPercentage)
|
||||
|
|
|
@ -147,7 +147,7 @@ func TestBatteryErrorHidden(t *testing.T) {
|
|||
env: env,
|
||||
}
|
||||
assert.True(t, b.enabled())
|
||||
assert.Equal(t, "100%", b.string())
|
||||
assert.Equal(t, "100", b.string())
|
||||
}
|
||||
|
||||
func TestBatteryDischargingAndDisplayChargingDisabled(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue