mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -08:00
fix: migrate exit segment correctly
This commit is contained in:
parent
42f9747558
commit
a091e5c387
|
@ -122,19 +122,19 @@ func (segment *Segment) migrationOne(env environment.Environment) {
|
||||||
segment.migrateColorOverride("version_mismatch_color", "{{ if .Mismatch }}%s{{ end }}")
|
segment.migrateColorOverride("version_mismatch_color", "{{ if .Mismatch }}%s{{ end }}")
|
||||||
}
|
}
|
||||||
case EXIT:
|
case EXIT:
|
||||||
segment.migrateTemplate()
|
|
||||||
template := segment.Properties.GetString(properties.SegmentTemplate, segment.writer.Template())
|
template := segment.Properties.GetString(properties.SegmentTemplate, segment.writer.Template())
|
||||||
displayExitCode := properties.Property("display_exit_code")
|
|
||||||
if !segment.Properties.GetBool(displayExitCode, true) {
|
|
||||||
delete(segment.Properties, displayExitCode)
|
|
||||||
template = strings.ReplaceAll(template, " {{ .Meaning }}", "")
|
|
||||||
}
|
|
||||||
alwaysNumeric := properties.Property("always_numeric")
|
alwaysNumeric := properties.Property("always_numeric")
|
||||||
if segment.Properties.GetBool(alwaysNumeric, false) {
|
if segment.Properties.GetBool(alwaysNumeric, false) {
|
||||||
delete(segment.Properties, alwaysNumeric)
|
delete(segment.Properties, alwaysNumeric)
|
||||||
template = strings.ReplaceAll(template, ".Meaning", ".Code")
|
template = strings.ReplaceAll(template, ".Meaning", ".Code")
|
||||||
}
|
}
|
||||||
|
displayExitCode := properties.Property("display_exit_code")
|
||||||
|
if !segment.Properties.GetBool(displayExitCode, true) {
|
||||||
|
delete(segment.Properties, displayExitCode)
|
||||||
|
template = " "
|
||||||
|
}
|
||||||
segment.Properties[properties.SegmentTemplate] = template
|
segment.Properties[properties.SegmentTemplate] = template
|
||||||
|
segment.migrateTemplate()
|
||||||
segment.migrateIconOverride("success_icon", "\uf42e")
|
segment.migrateIconOverride("success_icon", "\uf42e")
|
||||||
segment.migrateIconOverride("error_icon", "\uf00d")
|
segment.migrateIconOverride("error_icon", "\uf00d")
|
||||||
segment.migrateColorOverride("error_color", "{{ if gt .Code 0 }}%s{{ end }}")
|
segment.migrateColorOverride("error_color", "{{ if gt .Code 0 }}%s{{ end }}")
|
||||||
|
|
|
@ -220,8 +220,8 @@ func TestSegmentTemplateMigration(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Case: "EXIT - No exit Code with Icon overrides",
|
Case: "EXIT - No exit code",
|
||||||
Expected: " {{ if gt .Code 0 }}FAIL{{ else }}SUCCESS{{ end }} ",
|
Expected: " ",
|
||||||
Type: EXIT,
|
Type: EXIT,
|
||||||
Props: properties.Map{
|
Props: properties.Map{
|
||||||
"display_exit_code": false,
|
"display_exit_code": false,
|
||||||
|
|
Loading…
Reference in a new issue