From cee14fd4be36649aa96bb400ca3c2ed1937b4b5b Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 11 May 2015 08:57:50 +0100 Subject: Search completion; disable on redundant whitespace. --- pages/vomnibar.coffee | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee index a2e5c56a..6268afdd 100644 --- a/pages/vomnibar.coffee +++ b/pages/vomnibar.coffee @@ -214,8 +214,13 @@ class VomnibarUI return unless completion - # Fetch the query and suggestion. - query = @input.value.ltrim().split(/\s+/).join(" ").toLowerCase() + # Bail on leading whitespace or on redundant whitespace. This provides users with a way to force this + # feature off. + value = @input.value + return if /^\s/.test(value) or /\s\s/.test value + + # Fetch the query and the suggestion texts. + query = value.ltrim().split(/\s+/).join(" ").toLowerCase() suggestion = completion.title index = suggestion.toLowerCase().indexOf query -- cgit v1.2.3