Add comment explaining the need for appending \n when scanning lines with a TextMate grammar

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-10-16 16:07:54 -07:00
parent 6171ea33e1
commit 253a07e2c4

View File

@@ -93,9 +93,11 @@ class Rule
getNextTokens: (stack, line, position) ->
patterns = @getIncludedPatterns()
# Add a `\n` to appease patterns that contain '\n' explicitly
return null unless result = @getScanner().findNextMatch(line + "\n", position)
{ index, captureIndices } = result
# Since the `\n' (added above) is not part of the line, truncate captures to the line's actual length
lineLength = line.length
captureIndices = captureIndices.map (value, index) ->
value = lineLength if index % 3 != 0 and value > lineLength