From 403f7cbc6bbe6e5d567add6fd2bc4bf0f75db73a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 18 May 2015 11:19:08 -0700 Subject: [PATCH] Favor non bundle packages when breaking ties --- src/grammar-registry.coffee | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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