From 450f0ec3e105a3c0eeeeac1fc2c9d58c2fc88597 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 5 Nov 2012 15:13:44 +0000 Subject: Looks like missing parentheses. This is looks wrong, and is inconsistent with the way the equivalent calculation is handled elsewhere. This commit fixes it. --- background_scripts/completion.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 9e12d497..e959d358 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -171,7 +171,7 @@ class DomainCompleter for domain in domainCandidates recencyScore = RankingUtils.recencyScore(@domains[domain].lastVisitTime || 0) wordRelevancy = RankingUtils.wordRelevancy(queryTerms, domain, null) - score = wordRelevancy + Math.max(recencyScore, wordRelevancy) / 2 + score = (wordRelevancy + Math.max(recencyScore, wordRelevancy)) / 2 results.push([domain, score]) results.sort (a, b) -> b[1] - a[1] results -- cgit v1.2.3 From 8b02be8162033c77a68e75f4d9cff612f30d4edd Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 5 Nov 2012 15:17:25 +0000 Subject: Avoid empty query terms. With the previous version, a query like "hello there" yielded: [ "hello", "", "", "there" ] as the queryTerms. --- background_scripts/main.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 6ff3fa60..4c1b11ce 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -192,8 +192,9 @@ handleSettings = (args, port) -> refreshCompleter = (request) -> completers[request.name].refresh() +whitespaceRegexp = /\s+/ filterCompleter = (args, port) -> - queryTerms = if (args.query == "") then [] else args.query.split(" ") + queryTerms = if (args.query == "") then [] else args.query.split(whitespaceRegexp) completers[args.name].filter(queryTerms, (results) -> port.postMessage({ id: args.id, results: results })) getCurrentTimeInSeconds = -> Math.floor((new Date()).getTime() / 1000) -- cgit v1.2.3