From d9e0ba4f0a06b5f5543a4398434399497573336d Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 3 Nov 2012 10:57:36 +0000 Subject: Bug fix. Not all query terms matched. Additionally, add relevant test cases. --- background_scripts/completion.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index b0c04cce..ffc824ba 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -251,12 +251,15 @@ class MultiCompleter RankingUtils = # Whether the given things (usually URLs or titles) match any one of the query terms. # This is used to prune out irrelevant suggestions before we try to rank them, and for calculating word relevancy. + # Every term must match at least one thing. matches: (queryTerms, things...) -> for term in queryTerms regexp = RegexpCache.get(term) + matchedTerm = false for thing in things - return true if thing?.match && thing.match regexp - false + matchedTerm = matchedTerm || (thing?.match && thing.match regexp) + return false unless matchedTerm + true # Returns a number between [0, 1] indicating how often the query terms appear in the url and title. wordRelevancy: (queryTerms, url, title) -> -- cgit v1.2.3