diff options
| author | bors <bors@rust-lang.org> | 2019-04-12 08:59:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-04-12 08:59:03 +0000 |
| commit | 876a3bcb157a0ceb752adf972955d7413f870650 (patch) | |
| tree | 02d092be85a9b0d0122e233f3d5e4c21b84d6366 /src/librustdoc/html | |
| parent | 2226c09699a96520238e162777f44504f4a0a1a7 (diff) | |
| parent | 19073676bf75f9b8b1a0fb1cabde852845bc96b2 (diff) | |
| download | rust-876a3bcb157a0ceb752adf972955d7413f870650.tar.gz rust-876a3bcb157a0ceb752adf972955d7413f870650.zip | |
Auto merge of #59622 - GuillaumeGomez:improve-one-char-search, r=QuietMisdreavus
Ensure that exact matches come first in rustdoc search Fixes #59287. cc @scottmcm r? @QuietMisdreavus
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/static/main.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 412029cf376..00ca78b749e 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] = { |
