Pop stack when rule is pushed without position advancement

Previously only the scope name was checked which allowed cases
were rules without scope names to grow the stack infinitely without
advancing the position.

Closes atom/language-ruby-on-rails#1
This commit is contained in:
Kevin Sawicki
2013-12-04 15:16:53 -08:00
parent 31a909828d
commit 8af0a59c52
2 changed files with 20 additions and 3 deletions

View File

@@ -157,7 +157,16 @@ class TextMateGrammar
ruleStack.pop()
else if ruleStack.length > previousRuleStackLength # Stack size increased with zero length match
[penultimateRule, lastRule] = ruleStack[-2..]
# Same exact rule was pushed but position wasn't advanced
if lastRule? and lastRule == penultimateRule
popStack = true
# Rule with same scope name as previous rule was pushed but position wasn't advanced
if lastRule?.scopeName? and penultimateRule.scopeName == lastRule.scopeName
popStack = true
if popStack
ruleStack.pop()
tokens.push(new Token(
value: line[position...line.length]