From ee418ed5a03eaeaf591ebcdf748dd07534a9bc85 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 11 May 2015 08:55:49 +0100 Subject: Search completion; disable on redundant whitespace. --- pages/vomnibar.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee index 196ad766..855218ea 100644 --- a/pages/vomnibar.coffee +++ b/pages/vomnibar.coffee @@ -135,8 +135,13 @@ class VomnibarUI completions = @completions.filter (completion) -> completion.selectCommonMatches? and completion.selectCommonMatches + # 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 = @input.value.ltrim().split(/\s+/).join(" ").toLowerCase() + query = value.ltrim().split(/\s+/).join(" ").toLowerCase() suggestions = completions.map (completion) -> completion.title # Some completion engines add text at the start of the suggestion; for example, Bing takes "they might be" -- cgit v1.2.3