diff --git a/beetsplug/substitute.py b/beetsplug/substitute.py index ebf6cacbe..a89d0af16 100644 --- a/beetsplug/substitute.py +++ b/beetsplug/substitute.py @@ -34,9 +34,7 @@ class Substitute(BeetsPlugin): """Do the actual replacing.""" if text: for pattern, replacement in self.substitute_rules: - new_text, subs_made = pattern.subn(replacement, text) - if subs_made > 0: - return new_text + text = pattern.sub(replacement, text) return text else: return "" diff --git a/test/plugins/test_substitute.py b/test/plugins/test_substitute.py index 7ac74d7a0..48014e231 100644 --- a/test/plugins/test_substitute.py +++ b/test/plugins/test_substitute.py @@ -78,3 +78,13 @@ class SubstitutePluginTest(PluginTestCase): ("b", "y"), ], ) + + def test_rules_applied_in_sequence(self): + self.run_substitute( + {"a": "b", "b": "c", "d": "a"}, + [ + ("a", "c"), + ("b", "c"), + ("d", "a"), + ], + )