diff options
author | Kato Kazuyoshi <kato.kazuyoshi@gmail.com> | 2011-04-01 18:57:36 +0000 |
---|---|---|
committer | Kato Kazuyoshi <kato.kazuyoshi@gmail.com> | 2011-04-01 18:57:36 +0000 |
commit | 223428d1ebd13ddc96b7599db18d756efa532228 (patch) | |
tree | 40d1a36741f837c60d26b56a577ea36211f230e8 | |
parent | a6ba30b8eb1968979db92d3a006d57343983e684 (diff) | |
download | scala-223428d1ebd13ddc96b7599db18d756efa532228.tar.gz scala-223428d1ebd13ddc96b7599db18d756efa532228.tar.bz2 scala-223428d1ebd13ddc96b7599db18d756efa532228.zip |
On Scaladoc, we should escape meta characters b...
On Scaladoc, we should escape meta characters before compile regexp. No
review.
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js b/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js index 2d66d00b60..2aea2bedf8 100644 --- a/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js +++ b/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js @@ -227,25 +227,28 @@ function configureTextFilter() { }); } -// Filters all focused templates and packages. This function should be made less-blocking. -// @param query The string of the query -function textFilter() { - scheduler.clear("filter"); +function compilePattern(query) { + var escaped = query.replace(/([\.\*\+\?\|\(\)\[\]\\])/g, '\\$1'); - $('#tpl').html(''); - - var query = $("#textfilter input").attr("value") || ''; - - var queryRegExp; if (query.toLowerCase() != query) { // Regexp that matches CamelCase subbits: "BiSe" is // "[a-z]*Bi[a-z]*Se" and matches "BitSet", "ABitSet", ... - queryRegExp = new RegExp(query.replace(/([A-Z])/g,"[a-z]*$1")); + return new RegExp(escaped.replace(/([A-Z])/g,"[a-z]*$1")); } else { // if query is all lower case make a normal case insensitive search - queryRegExp = new RegExp(query, "i"); + return new RegExp(escaped, "i"); } +} +// Filters all focused templates and packages. This function should be made less-blocking. +// @param query The string of the query +function textFilter() { + scheduler.clear("filter"); + + $('#tpl').html(''); + + var query = $("#textfilter input").attr("value") || ''; + var queryRegExp = compilePattern(query); var index = 0; |