From c628508ce66f9f32ae88f36ae57a6b44f900ef88 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 11 May 2015 08:47:57 +0100 Subject: Domain completer should not complete with trailing whitespace. --- background_scripts/completion.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 3ddb21d2..a12f1bcf 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -231,8 +231,8 @@ class DomainCompleter # If `referenceCount` goes to zero, the domain entry can and should be deleted. domains: null - filter: ({ queryTerms }, onComplete) -> - return onComplete([]) unless queryTerms.length == 1 + filter: ({ queryTerms, query }, onComplete) -> + return onComplete [] unless queryTerms.length == 1 and not /\s$/.test query if @domains @performSearch(queryTerms, onComplete) else -- cgit v1.2.3 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