about summary refs log tree commit diff
path: root/src/librustdoc/html/static
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2022-03-30 11:32:03 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2022-04-18 20:59:09 +0200
commite03a9507471f5239d7cb51108f44994bc23bf234 (patch)
tree023c9057d6ee5884ce2bf184d2546c938dfa0f92 /src/librustdoc/html/static
parentda829d8d9de73f196b17ab5e8b4a4c07863e30c9 (diff)
downloadrust-e03a9507471f5239d7cb51108f44994bc23bf234.tar.gz
rust-e03a9507471f5239d7cb51108f44994bc23bf234.zip
Handle separators in their own functions and fix missing handling of tabs
Diffstat (limited to 'src/librustdoc/html/static')
-rw-r--r--src/librustdoc/html/static/js/search.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index 239fef494ad..7a318cbfa45 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -227,6 +227,17 @@ window.initSearch = function(rawSearchIndex) {
     }
 
     /**
+     * Returns `true` if the given `c` character is a separator.
+     *
+     * @param {string} c
+     *
+     * @return {boolean}
+     */
+    function isSeparatorCharacter(c) {
+        return ", \t".indexOf(c) !== -1;
+    }
+
+    /**
      * @param {ParsedQuery} query
      * @param {ParserState} parserState
      * @param {string} name                  - Name of the query element.
@@ -295,7 +306,11 @@ window.initSearch = function(rawSearchIndex) {
                 if (!isIdentCharacter(c)) {
                     if (isErrorCharacter(c)) {
                         throw new Error(`Unexpected \`${c}\``);
-                    } else if (isStopCharacter(c) || isSpecialStartCharacter(c)) {
+                    } else if (
+                        isStopCharacter(c) ||
+                        isSpecialStartCharacter(c) ||
+                        isSeparatorCharacter(c))
+                    {
                         break;
                     }
                     // If we allow paths ("str::string" for example).
@@ -358,7 +373,7 @@ window.initSearch = function(rawSearchIndex) {
             var c = parserState.userQuery[parserState.pos];
             if (c === endChar) {
                 break;
-            } else if (c === "," || c === " ") {
+            } else if (isSeparatorCharacter(c)) {
                 parserState.pos += 1;
                 foundStopChar = true;
                 continue;
@@ -409,7 +424,7 @@ window.initSearch = function(rawSearchIndex) {
             c = parserState.userQuery[parserState.pos];
             if (isStopCharacter(c)) {
                 foundStopChar = true;
-                if (c === "," || c === " ") {
+                if (isSeparatorCharacter(c)) {
                     parserState.pos += 1;
                     continue;
                 } else if (c === "-" || c === ">") {