mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-26 19:39: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 }}")
|
||||
}
|
||||
case EXIT:
|
||||
segment.migrateTemplate()
|
||||
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")
|
||||
if segment.Properties.GetBool(alwaysNumeric, false) {
|
||||
delete(segment.Properties, alwaysNumeric)
|
||||
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.migrateTemplate()
|
||||
segment.migrateIconOverride("success_icon", "\uf42e")
|
||||
segment.migrateIconOverride("error_icon", "\uf00d")
|
||||
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",
|
||||
Expected: " {{ if gt .Code 0 }}FAIL{{ else }}SUCCESS{{ end }} ",
|
||||
Case: "EXIT - No exit code",
|
||||
Expected: " ",
|
||||
Type: EXIT,
|
||||
Props: properties.Map{
|
||||
"display_exit_code": false,
|
||||
|
|
Loading…
Reference in a new issue