From edd4752268b266d697be51733599b708e4ae449a Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Thu, 1 Jun 2023 12:50:59 -0500 Subject: config: fix multiple dynamic styles When a user sets multiple dynamic styles, only the first one is applied. The parsing function is modifying the matching pattern prior to saving it to the style. When a second occurrence of the same dynamic style is seen, the patterns don't match because we compare against the raw user input instead of the modified pattern value. Store the raw user input as the pattern instead of our modified regex. Fixes: 2f46f64b0b0b ("styleset: allow dynamic msglist styling") Reported-by: Drew Devault Signed-off-by: Tim Culverhouse Tested-by: Drew Devault Acked-by: Robin Jarry --- config/style.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config/style.go b/config/style.go index ee171fcb..511cdb3a 100644 --- a/config/style.go +++ b/config/style.go @@ -466,6 +466,10 @@ func (c *StyleConf) update(header, pattern, attr, val string) error { return s.Set(attr, val) } } + s := Style{ + header: header, + pattern: pattern, + } if strings.HasPrefix(pattern, "~") { pattern = pattern[1:] } else { @@ -475,13 +479,10 @@ func (c *StyleConf) update(header, pattern, attr, val string) error { if err != nil { return err } - var s Style err = (&s).Set(attr, val) if err != nil { return err } - s.header = header - s.pattern = pattern s.re = re c.dynamic = append(c.dynamic, s) return nil -- cgit