This commit is contained in:
Corey Johnson & Nathan Sobo 2012-09-28 09:36:37 -07:00
parent 66ac4503a7
commit ae4db9d238

View File

@ -38,23 +38,22 @@ class TextMateGrammar
break if position == line.length
{ nextTokens, tokensStartPosition, tokensEndPosition } = _.last(stack).getNextTokens(stack, line, position)
if match = _.last(stack).getNextTokens(stack, line, position)
{ nextTokens, tokensStartPosition, tokensEndPosition } = match
if position < tokensStartPosition # unmatched text before next tokens
tokens.push
value: line[position...tokensStartPosition]
scopes: scopes
if position < tokensStartPosition # unmatched text before next tokens
tokens.push
value: line[position...tokensStartPosition]
scopes: scopes
if nextTokens
tokens.push(nextTokens...)
else # unmatched text after last token
position = tokensEndPosition
else # push filler token for unmatched text at end of line
tokens.push
value: line[position...line.length]
scopes: scopes
break
position = tokensEndPosition
{ tokens, stack }
ruleForInclude: (name) ->
@ -91,7 +90,7 @@ class Rule
getNextTokens: (stack, line, position) ->
patterns = @getIncludedPatterns()
return {} unless result = @getScanner().findNextMatch(line, position)
return null unless result = @getScanner().findNextMatch(line, position)
{ index, captureIndices } = result
[firstCaptureIndex, firstCaptureStart, firstCaptureEnd] = captureIndices