mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-03 15:27:26 -08:00
parent
d62c3d6e37
commit
4641146b1e
|
@ -43,13 +43,20 @@ func (b *batt) enabled() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
displayError := b.props.getBool(DisplayError, false)
|
displayError := b.props.getBool(DisplayError, false)
|
||||||
if err != nil && !displayError {
|
if err != nil && displayError {
|
||||||
b.percentageText = "100%"
|
b.percentageText = "BATT ERR"
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.percentageText = "BATT ERR"
|
// On Windows, it sometimes errors when the battery is full.
|
||||||
return true
|
// 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 := bt.Current / bt.Full * 100
|
||||||
batteryPercentage = math.Min(100, batteryPercentage)
|
batteryPercentage = math.Min(100, batteryPercentage)
|
||||||
|
|
|
@ -147,7 +147,7 @@ func TestBatteryErrorHidden(t *testing.T) {
|
||||||
env: env,
|
env: env,
|
||||||
}
|
}
|
||||||
assert.True(t, b.enabled())
|
assert.True(t, b.enabled())
|
||||||
assert.Equal(t, "100%", b.string())
|
assert.Equal(t, "100", b.string())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBatteryDischargingAndDisplayChargingDisabled(t *testing.T) {
|
func TestBatteryDischargingAndDisplayChargingDisabled(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue