diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-09-12 20:02:17 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-12 20:02:17 +1000 |
| commit | 249730f521921016e19d226a7799d5bdc879f8f2 (patch) | |
| tree | ed996610b0392bf5aedefa23a775a44011b9e688 /src | |
| parent | 2e51a389996f63f06b2346874de55ede682d7a76 (diff) | |
| parent | 04a1dd1c175cb0fc18419e0261f99bf35199ab59 (diff) | |
| download | rust-249730f521921016e19d226a7799d5bdc879f8f2.tar.gz rust-249730f521921016e19d226a7799d5bdc879f8f2.zip | |
Rollup merge of #146448 - GuillaumeGomez:fix-literal-search-paths, r=lolbinarycat
[rustdoc] Correctly handle literal search on paths Fixes https://github.com/rust-lang/rust/issues/146129. cc ```@notriddle``` r? ```@lolbinarycat```
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/html/static/js/search.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index b01b596da68..3b84ae2bed0 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -3639,7 +3639,7 @@ class DocSearch { if (contains.length === 0) { return 0; } - const maxPathEditDistance = Math.floor( + const maxPathEditDistance = parsedQuery.literalSearch ? 0 : Math.floor( contains.reduce((acc, next) => acc + next.length, 0) / 3, ); let ret_dist = maxPathEditDistance + 1; @@ -3650,7 +3650,9 @@ class DocSearch { let dist_total = 0; for (let x = 0; x < clength; ++x) { const [p, c] = [path[i + x], contains[x]]; - if (Math.floor((p.length - c.length) / 3) <= maxPathEditDistance && + if (parsedQuery.literalSearch && p !== c) { + continue pathiter; + } else if (Math.floor((p.length - c.length) / 3) <= maxPathEditDistance && p.indexOf(c) !== -1 ) { // discount distance on substring match |
