diff --git a/src/grammar-registry.coffee b/src/grammar-registry.coffee index 568de483a..bccfd4569 100644 --- a/src/grammar-registry.coffee +++ b/src/grammar-registry.coffee @@ -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