]> git.lizzy.rs Git - rust.git/commit
rustdoc: simplify JS search routine by not messing with lev distance
authorMichael Howell <michael@notriddle.com>
Fri, 16 Dec 2022 18:12:59 +0000 (11:12 -0700)
committerMichael Howell <michael@notriddle.com>
Sat, 14 Jan 2023 19:04:11 +0000 (12:04 -0700)
commit59ba74cacb87ac89f7f5fcb5233eaccb50dd8349
tree984fd0b11fea32d0232d95c46d802770cfd34112
parent4b51adf6ffa1ae2286ea436eb48cbaa8771886e6
rustdoc: simplify JS search routine by not messing with lev distance

Since the sorting function accounts for an `index` field, there's not much
reason to also be applying changes to the levenshtein distance. Instead,
we can just not treat `lev` as a filter if there's already a non-sentinel
value for `index`.

This change gives slightly more weight to the index and path part, as
search criteria, than it used to. This changes some of the test cases,
but not in any obviously-"worse" way, and, in particular, substring matches
are a bigger deal than levenshtein distances (we're assuming that a typo
is less likely than someone just not typing the entire name).

Based on
https://github.com/rust-lang/rust/pull/103710#issuecomment-1296894296
src/librustdoc/html/static/js/search.js