aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-08-03 23:39:01 +0200
committerRobin Jarry <robin@jarry.cc>2023-08-04 23:41:50 +0200
commitb00c4965bb36071db6a366f5acc3623f6037480c (patch)
tree11ed7a45c09beb90e546e4bcc2e663fe54aafd3c
parent2330d5e493443fa35544ad078a7c4228b9d33541 (diff)
downloadaerc-b00c4965bb36071db6a366f5acc3623f6037480c.tar.gz
aerc-b00c4965bb36071db6a366f5acc3623f6037480c.zip
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 <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
-rw-r--r--config/ui.go9
1 files 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
}