~rjarry/aerc

edd4752268b266d697be51733599b708e4ae449a — Tim Culverhouse a day ago 5f5514d master
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 <sir@cmpwn.com>
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Drew Devault <sir@cmpwn.com>
Acked-by: Robin Jarry <robin@jarry.cc>
1 files changed, 4 insertions(+), 3 deletions(-)

M config/style.go
M config/style.go => config/style.go +4 -3
@@ 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