aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2015-05-11 08:57:50 +0100
committerStephen Blott2015-05-11 08:57:50 +0100
commitcee14fd4be36649aa96bb400ca3c2ed1937b4b5b (patch)
tree97858ec3d92175e451122a5184abc6ea1f03afda
parentf3156e30e7f1a347a5a7cfa755ad196e2948d78d (diff)
downloadvimium-cee14fd4be36649aa96bb400ca3c2ed1937b4b5b.tar.bz2
Search completion; disable on redundant whitespace.
-rw-r--r--pages/vomnibar.coffee9
1 files 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