From 09388116122f75c8f1e22298dcfd189fe445a76c Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 21 Dec 2012 09:33:52 -0800 Subject: [PATCH] Clear anchor positions in stack after line is tokenized --- src/app/text-mate-grammar.coffee | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/text-mate-grammar.coffee b/src/app/text-mate-grammar.coffee index 9aa30bee6..d132d6738 100644 --- a/src/app/text-mate-grammar.coffee +++ b/src/app/text-mate-grammar.coffee @@ -61,6 +61,7 @@ class TextMateGrammar )) break + ruleStack.forEach (rule) -> rule.clearAnchorPosition() { tokens, ruleStack } ruleForInclude: (name) -> @@ -78,7 +79,7 @@ class Rule patterns: null allPatterns: null createEndPattern: null - anchor: -1 + anchorPosition: -1 constructor: (@grammar, {@scopeName, patterns, @endPattern}) -> patterns ?= [] @@ -95,6 +96,8 @@ class Rule @allPatterns.push(pattern.getIncludedPatterns(included)...) @allPatterns + clearAnchorPosition: -> @anchorPosition = -1 + getScanner: (position, firstLine) -> return @scanner if @scanner @@ -103,7 +106,7 @@ class Rule @getIncludedPatterns().forEach (pattern) => if pattern.anchored anchored = true - regex = pattern.replaceAnchor(firstLine, position, @anchor) + regex = pattern.replaceAnchor(firstLine, position, @anchorPosition) else regex = pattern.regexSource regexes.push regex if regex @@ -232,7 +235,7 @@ class Pattern tokens = [new Token(value: line[start...end], scopes: scopes)] if @pushRule ruleToPush = @pushRule.getRuleToPush(line, captureIndices) - ruleToPush.anchor = captureIndices[2] + ruleToPush.anchorPosition = captureIndices[2] stack.push(ruleToPush) else if @popRule stack.pop()