mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user