From 06291e168bb51e34236200f695e3934d6d095d6a Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Sat, 5 Feb 2022 09:41:41 +0100 Subject: [PATCH] fix(migrate): replace .Text with .Meaning resolves #1697 --- src/engine/migrate.go | 4 ++++ src/engine/migrate_test.go | 8 ++++++++ themes/agnoster.omp.json | 2 +- themes/avit.omp.json | 2 +- themes/blue-owl.omp.json | 2 +- themes/darkblood.omp.json | 2 +- themes/emodipt.omp.json | 2 +- themes/fish.omp.json | 2 +- themes/honukai.omp.json | 2 +- themes/jblab_2021.omp.json | 2 +- themes/nordtron.omp.json | 2 +- themes/powerlevel10k_rainbow.omp.json | 2 +- themes/sorin.omp.json | 2 +- 13 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/engine/migrate.go b/src/engine/migrate.go index 6c97ad32..c196f8fa 100644 --- a/src/engine/migrate.go +++ b/src/engine/migrate.go @@ -127,6 +127,10 @@ func (segment *Segment) migrationOne(env environment.Environment) { } case EXIT: template := segment.Properties.GetString(properties.SegmentTemplate, segment.writer.Template()) + if strings.Contains(template, ".Text") { + template = strings.ReplaceAll(template, ".Text", ".Meaning") + segment.Properties[properties.SegmentTemplate] = template + } alwaysNumeric := properties.Property("always_numeric") if segment.Properties.GetBool(alwaysNumeric, false) { delete(segment.Properties, alwaysNumeric) diff --git a/src/engine/migrate_test.go b/src/engine/migrate_test.go index 6d392f97..a815eafd 100644 --- a/src/engine/migrate_test.go +++ b/src/engine/migrate_test.go @@ -239,6 +239,14 @@ func TestSegmentTemplateMigration(t *testing.T) { "error_icon": "FAIL", }, }, + { + Case: "EXIT - .Text", + Expected: " {{ .Meaning }} ", + Type: EXIT, + Props: properties.Map{ + "template": "{{ .Text }}", + }, + }, { Case: "BATTERY", Expected: ` {{ if not .Error }}{{ $stateList := list "Discharging" "Full" }}{{ if has .State.String $stateList }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ end }}{{ .Error }} `, diff --git a/themes/agnoster.omp.json b/themes/agnoster.omp.json index ab888ba4..1ef835a2 100644 --- a/themes/agnoster.omp.json +++ b/themes/agnoster.omp.json @@ -63,7 +63,7 @@ "foreground": "#ffffff", "powerline_symbol": "\ue0b0", "properties": { - "template": " {{ .Text }} " + "template": " {{ .Meaning }} " }, "style": "powerline", "type": "exit" diff --git a/themes/avit.omp.json b/themes/avit.omp.json index c2ebd6c5..bb1018c9 100644 --- a/themes/avit.omp.json +++ b/themes/avit.omp.json @@ -32,7 +32,7 @@ { "foreground": "#C94A16", "properties": { - "template": "x{{ .Text }} " + "template": "x{{ .Meaning }} " }, "style": "plain", "type": "exit" diff --git a/themes/blue-owl.omp.json b/themes/blue-owl.omp.json index bff890be..4ce50f23 100644 --- a/themes/blue-owl.omp.json +++ b/themes/blue-owl.omp.json @@ -73,7 +73,7 @@ "foreground": "#ffffff", "powerline_symbol": "\ue0b0", "properties": { - "template": " \uf12a {{ .Text }} " + "template": " \uf12a {{ .Meaning }} " }, "style": "powerline", "type": "exit" diff --git a/themes/darkblood.omp.json b/themes/darkblood.omp.json index 22f03031..e527f8f4 100644 --- a/themes/darkblood.omp.json +++ b/themes/darkblood.omp.json @@ -31,7 +31,7 @@ { "foreground": "#ffffff", "properties": { - "template": "<#CB4B16>[x{{ .Text }}<#CB4B16>]" + "template": "<#CB4B16>[x{{ .Meaning }}<#CB4B16>]" }, "style": "plain", "type": "exit" diff --git a/themes/emodipt.omp.json b/themes/emodipt.omp.json index 07112b77..c7d6e618 100644 --- a/themes/emodipt.omp.json +++ b/themes/emodipt.omp.json @@ -43,7 +43,7 @@ { "foreground": "#C94A16", "properties": { - "template": "x{{ .Text }} " + "template": "x{{ .Meaning }} " }, "style": "plain", "type": "exit" diff --git a/themes/fish.omp.json b/themes/fish.omp.json index 9d8d5b8e..a004cc5e 100644 --- a/themes/fish.omp.json +++ b/themes/fish.omp.json @@ -7,7 +7,7 @@ { "foreground": "#ffffff", "properties": { - "template": " {{ .Text }}" + "template": " {{ .Meaning }}" }, "style": "plain", "type": "exit" diff --git a/themes/honukai.omp.json b/themes/honukai.omp.json index 1e63bcf3..b557dab9 100644 --- a/themes/honukai.omp.json +++ b/themes/honukai.omp.json @@ -71,7 +71,7 @@ { "foreground": "#CB4B16", "properties": { - "template": " {{ .Text }} " + "template": " {{ .Meaning }} " }, "style": "plain", "type": "exit" diff --git a/themes/jblab_2021.omp.json b/themes/jblab_2021.omp.json index d0603462..d6297681 100644 --- a/themes/jblab_2021.omp.json +++ b/themes/jblab_2021.omp.json @@ -90,7 +90,7 @@ "foreground": "#ffffff", "leading_diamond": "\ue0b0", "properties": { - "template": " \uf12a {{ .Text }} " + "template": " \uf12a {{ .Meaning }} " }, "style": "diamond", "trailing_diamond": "\ue0b0", diff --git a/themes/nordtron.omp.json b/themes/nordtron.omp.json index 9ff1bc16..10ae6284 100644 --- a/themes/nordtron.omp.json +++ b/themes/nordtron.omp.json @@ -50,7 +50,7 @@ { "foreground": "#d8dee9", "properties": { - "template": "<#5e81ac>[x{{ .Text }}<#5e81ac>]" + "template": "<#5e81ac>[x{{ .Meaning }}<#5e81ac>]" }, "style": "plain", "type": "exit" diff --git a/themes/powerlevel10k_rainbow.omp.json b/themes/powerlevel10k_rainbow.omp.json index 51c49696..d8a8f930 100644 --- a/themes/powerlevel10k_rainbow.omp.json +++ b/themes/powerlevel10k_rainbow.omp.json @@ -174,7 +174,7 @@ "powerline_symbol": "\ue0b2", "properties": { "always_enabled": true, - "template": " {{ if gt .Code 0 }}{{ .Text }}{{ else }}\u2714{{ end }} " + "template": " {{ if gt .Code 0 }}{{ .Meaning }}{{ else }}\u2714{{ end }} " }, "style": "powerline", "type": "exit" diff --git a/themes/sorin.omp.json b/themes/sorin.omp.json index 607cf805..a8aced94 100644 --- a/themes/sorin.omp.json +++ b/themes/sorin.omp.json @@ -7,7 +7,7 @@ { "foreground": "#CB4B16", "properties": { - "template": " {{ .Text }} " + "template": " {{ .Meaning }} " }, "style": "plain", "type": "exit"