mirror of
https://github.com/atom/atom.git
synced 2026-02-12 15:45:23 -05:00
Fix how repositories work in TextMate grammars
Previously, we treated all grammar repositories as rules, but some grammars have repositories that are a single pattern. If it is a single pattern, transform it into a rule with one pattern. Fix how repositories work in TextMate grammars Previously, we treated all grammar repositories as rules, but some grammars have repositories that are a single pattern. If it is a single pattern, transform it into a rule with one pattern.
This commit is contained in:
@@ -26,6 +26,7 @@ class TextMateGrammar
|
||||
@firstLineRegex = new OnigRegExp(firstLineMatch) if firstLineMatch
|
||||
|
||||
for name, data of repository
|
||||
data = {patterns: [data], tempName: name} if data.begin? or data.match?
|
||||
@repository[name] = new Rule(this, data)
|
||||
|
||||
tokenizeLine: (line, {ruleStack, tabLength}={}) ->
|
||||
@@ -111,7 +112,6 @@ class Rule
|
||||
# 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) ->
|
||||
|
||||
Reference in New Issue
Block a user