diff --git a/assets/javascripts/app/searcher.coffee b/assets/javascripts/app/searcher.coffee index 3b97fae9..bf5f8a5b 100644 --- a/assets/javascripts/app/searcher.coffee +++ b/assets/javascripts/app/searcher.coffee @@ -135,6 +135,7 @@ class app.Searcher # index = # position of the query in the string being matched + lastIndex = # last position of the query in the string being matched match = # regexp match data score = # score for the current match separators = # counter @@ -144,6 +145,14 @@ class app.Searcher index = value.indexOf @query return unless index >= 0 + lastIndex = value.lastIndexOf @query + + if index isnt lastIndex + Math.max(@scoreExactMatch(value, index), @scoreExactMatch(value, lastIndex)) + else + @scoreExactMatch(value, index) + + scoreExactMatch: (value, index) -> # Remove one point for each unmatched character. score = 100 - (value.length - @queryLength)