about summary refs log tree commit diff
path: root/src/librustdoc/html
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2019-04-02 00:07:51 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2019-04-02 00:09:27 +0200
commit19073676bf75f9b8b1a0fb1cabde852845bc96b2 (patch)
treec8fb457765e8b79a77ab23a12ac59a211dbc47b8 /src/librustdoc/html
parent2002b4b39a16760f37107cf02d7a91ff316d3073 (diff)
downloadrust-19073676bf75f9b8b1a0fb1cabde852845bc96b2.tar.gz
rust-19073676bf75f9b8b1a0fb1cabde852845bc96b2.zip
Ensure that exact matches come first in rustdoc search
Diffstat (limited to 'src/librustdoc/html')
-rw-r--r--src/librustdoc/html/static/main.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index aad7eb627bf..1748c48dd27 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -930,10 +930,10 @@ if (!DOMTokenList.prototype.remove) {
                     returned = checkReturned(ty, output, true);
                     if (output.name === "*" || returned === true) {
                         in_args = false;
-                        var module = false;
+                        var is_module = false;
 
                         if (input === "*") {
-                            module = true;
+                            is_module = true;
                         } else {
                             var allFound = true;
                             for (var it = 0; allFound === true && it < inputs.length; it++) {
@@ -955,7 +955,7 @@ if (!DOMTokenList.prototype.remove) {
                                 dontValidate: true,
                             };
                         }
-                        if (module === true) {
+                        if (is_module === true) {
                             results[fullId] = {
                                 id: i,
                                 index: -1,
@@ -1073,6 +1073,10 @@ if (!DOMTokenList.prototype.remove) {
                     if (index !== -1 || lev <= MAX_LEV_DISTANCE) {
                         if (index !== -1 && paths.length < 2) {
                             lev = 0;
+                        } else if (searchWords[j] === val) {
+                            // Small trick to fix when you're looking for a one letter type
+                            // and there are other short named types.
+                            lev = -1;
                         }
                         if (results[fullId] === undefined) {
                             results[fullId] = {