aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorStephen Blott2012-11-13 22:18:06 +0000
committerStephen Blott2012-11-13 22:18:06 +0000
commit4dc517401a2d01d34455498ff805e81f7f4f2674 (patch)
tree93926e867a8db947262c8a9cb795ff9391c27dc2 /background_scripts
parent85bffd2dd8ef75b7c50d6851350490aea4c184cd (diff)
downloadvimium-4dc517401a2d01d34455498ff805e81f7f4f2674.tar.bz2
Smartcase matching for vomnibar.
Vomnibar queries are case insensitive, unless the query contains a capital letter.
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/completion.coffee5
1 files changed, 4 insertions, 1 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index 28bb1afa..c99a94cb 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -355,7 +355,10 @@ RegexpCache =
# Avoid cost of constructing new strings if prefix/suffix are empty (which is expected to be a common case).
regexpString = prefix + regexpString if prefix
regexpString = regexpString + suffix if suffix
- @cache[regexpString] ||= new RegExp(regexpString, "i")
+ return @cache[regexpString] if @cache[regexpString]
+ # Smartcase: regexp is case insensitive, unless `string` contains a capital letter.
+ modifier = if /[A-Z]/.test string then "" else "i"
+ @cache[regexpString] = new RegExp(regexpString, modifier)
# Provides cached access to Chrome's history. As the user browses to new pages, we add those pages to this
# history cache.