Favor non bundle packages when breaking ties

This commit is contained in:
Kevin Sawicki
2015-05-18 11:19:08 -07:00
parent db9b655d49
commit 403f7cbc6b

View File

@@ -35,7 +35,16 @@ class GrammarRegistry extends FirstMate.GrammarRegistry
# * `fileContents` A {String} of text for the file path.
#
# Returns a {Grammar}, never null.
selectGrammar: (filePath, fileContents) -> super
selectGrammar: (filePath, fileContents) ->
bestMatch = null
highestScore = -Infinity
for grammar in @grammars
score = grammar.getScore(filePath, fileContents)
if score > highestScore
bestMatch = grammar
else if score is highestScore
bestMatch = grammar if bestMatch.bundledPackage and not grammar.bundledPackage
bestMatch
clearObservers: ->
@off() if includeDeprecatedAPIs