diff --git a/src/TextMateSharp/Internal/Rules/BeginEndRule.cs b/src/TextMateSharp/Internal/Rules/BeginEndRule.cs index a925a71..60bb9ca 100644 --- a/src/TextMateSharp/Internal/Rules/BeginEndRule.cs +++ b/src/TextMateSharp/Internal/Rules/BeginEndRule.cs @@ -42,16 +42,17 @@ public override void CollectPatternsRecursive(IRuleRegistry grammar, RegExpSourc { if (isFirst) { + // This is the first time this is called foreach (RuleId pattern in this.Patterns) { Rule rule = grammar.GetRule(pattern); rule.CollectPatternsRecursive(grammar, sourceList, false); } + + return; } - else - { - sourceList.Push(this._begin); - } + + sourceList.Push(this._begin); } public override CompiledRule Compile(IRuleRegistry grammar, string endRegexSource, bool allowA, bool allowG)