mirror of
https://github.com/atom/atom.git
synced 2026-02-07 05:05:02 -05:00
Pop grammar rules that result in infinite loops
This commit is contained in:
@@ -31,9 +31,10 @@ class TextMateGrammar
|
||||
ruleStack = new Array(ruleStack...) # clone ruleStack
|
||||
tokens = []
|
||||
position = 0
|
||||
|
||||
loop
|
||||
scopes = scopesFromStack(ruleStack)
|
||||
previousRuleStackLength = ruleStack.length
|
||||
previousPosition = position
|
||||
|
||||
if line.length == 0
|
||||
tokens = [new Token(value: "", scopes: scopes)]
|
||||
@@ -61,6 +62,10 @@ class TextMateGrammar
|
||||
))
|
||||
break
|
||||
|
||||
if position == previousPosition and ruleStack.length == previousRuleStackLength
|
||||
console.error("Popping rule because it loops at column #{position} of line '#{line}'", _.clone(ruleStack))
|
||||
ruleStack.pop()
|
||||
|
||||
ruleStack.forEach (rule) -> rule.clearAnchorPosition()
|
||||
{ tokens, ruleStack }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user