From b00c4965bb36071db6a366f5acc3623f6037480c Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Thu, 3 Aug 2023 23:39:01 +0200 Subject: config: fix contextual ui config Re-parse the contextual UI config over the existing UI config in order to avoid the zero-value overwrite issue. This fixes the usage of bool config variables in the contextual sections (such as threading-enabled). Fixes: https://todo.sr.ht/~rjarry/aerc/121 Signed-off-by: Koni Marti Acked-by: Robin Jarry Tested-by: Bence Ferdinandy --- config/ui.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/config/ui.go b/config/ui.go index ff6fbccf..699e8a0f 100644 --- a/config/ui.go +++ b/config/ui.go @@ -15,7 +15,6 @@ import ( "github.com/emersion/go-message/mail" "github.com/gdamore/tcell/v2" "github.com/go-ini/ini" - "github.com/imdario/mergo" ) type UIConfig struct { @@ -94,6 +93,7 @@ type UiConfigContext struct { ContextType uiContextType Regex *regexp.Regexp UiConfig *UIConfig + Section ini.Section } type uiContextKey struct { @@ -138,6 +138,7 @@ func parseUi(file *ini.File) error { } contextualUi := UiConfigContext{ UiConfig: &uiSubConfig, + Section: *section, } switch ctx { @@ -484,14 +485,14 @@ func (base *UIConfig) mergeContextual( if !contextualUi.Regex.Match([]byte(s)) { continue } - // Try to make this as lightweight as possible and avoid copying - // the base UIConfig object unless necessary. ui := *base - err := mergo.Merge(&ui, contextualUi.UiConfig, mergo.WithOverride) + err := ui.parse(&contextualUi.Section) if err != nil { log.Warnf("merge ui failed: %v", err) } ui.contextualCache = make(map[uiContextKey]*UIConfig) + ui.contextualCounts = base.contextualCounts + ui.contextualUis = base.contextualUis if contextualUi.UiConfig.StyleSetName != "" { ui.style = contextualUi.UiConfig.style } -- cgit v1.2.3-54-g00ecf