aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorPhil Crosby2015-09-20 23:41:36 -0700
committerPhil Crosby2015-09-20 23:41:36 -0700
commitb2a194a58def7a3b1084a6f338bb48d6edd9397b (patch)
treeca4f517e1ce4fe8cc64d3066bfcbbb41e98408f8 /background_scripts
parent34452f22ec4c6403deecb59b73d237bcfa7c964a (diff)
parent011a6b01fd2d05b5e3fa0181d6b5477e105616ca (diff)
downloadvimium-b2a194a58def7a3b1084a6f338bb48d6edd9397b.tar.bz2
Merge pull request #1086 from mrmr1993/countMatches
Rework to make match counting code for searches more DRY and easier to read
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/completion.coffee4
1 files changed, 1 insertions, 3 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index fb5a6120..2427bad8 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -762,8 +762,6 @@ RegexpCache =
init: ->
@initialized = true
@clear()
- # Taken from http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
- @escapeRegExp ||= /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g
clear: -> @cache = {}
@@ -777,7 +775,7 @@ RegexpCache =
# TODO: `prefix` and `suffix` might be useful in richer word-relevancy scoring.
get: (string, prefix="", suffix="") ->
@init() unless @initialized
- regexpString = string.replace(@escapeRegExp, "\\$&")
+ regexpString = Utils.escapeRegexSpecialCharacters string
# 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