Skip to content

Commit 83d154a

Browse files
committed
js: rustdoc.Results has a max_dist field
1 parent ccf3198 commit 83d154a

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/librustdoc/html/static/js/rustdoc.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ declare namespace rustdoc {
129129

130130
/**
131131
* A single parsed "atom" in a search query. For example,
132-
*
132+
*
133133
* std::fmt::Formatter, Write -> Result<()>
134134
* ┏━━━━━━━━━━━━━━━━━━ ┌──── ┏━━━━━┅┅┅┅┄┄┄┄┄┄┄┄┄┄┄┄┄┄┐
135135
* ┃ │ ┗ QueryElement { ┊
@@ -239,7 +239,7 @@ declare namespace rustdoc {
239239
query: ParsedQuery,
240240
}
241241

242-
type Results = Map<String, ResultObject>;
242+
type Results = { max_dist?: number } & Map<String, ResultObject>
243243

244244
/**
245245
* An annotated `Row`, used in the viewmodel.

src/librustdoc/html/static/js/search.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,7 +2520,11 @@ class DocSearch {
25202520
* @return {Promise<rustdoc.ResultsTable>}
25212521
*/
25222522
async execQuery(origParsedQuery, filterCrates, currentCrate) {
2523-
const results_others = new Map(), results_in_args = new Map(),
2523+
/** @type {rustdoc.Results} */
2524+
const results_others = new Map(),
2525+
/** @type {rustdoc.Results} */
2526+
results_in_args = new Map(),
2527+
/** @type {rustdoc.Results} */
25242528
results_returned = new Map();
25252529

25262530
/** @type {rustdoc.ParsedQuery<rustdoc.QueryElement>} */
@@ -4451,7 +4455,6 @@ class DocSearch {
44514455
return;
44524456
}
44534457

4454-
// @ts-expect-error
44554458
results.max_dist = Math.max(results.max_dist || 0, tfpDist);
44564459
addIntoResults(results, row.id.toString(), pos, 0, tfpDist, 0, Number.MAX_VALUE);
44574460
}
@@ -4560,29 +4563,23 @@ class DocSearch {
45604563
const returned = row.type && row.type.output
45614564
&& checkIfInList(row.type.output, elem, row.type.where_clause, null, 0);
45624565
if (in_args) {
4563-
// @ts-expect-error
45644566
results_in_args.max_dist = Math.max(
4565-
// @ts-expect-error
45664567
results_in_args.max_dist || 0,
45674568
tfpDist,
45684569
);
45694570
const maxDist = results_in_args.size < MAX_RESULTS ?
45704571
(tfpDist + 1) :
4571-
// @ts-expect-error
45724572
results_in_args.max_dist;
45734573
// @ts-expect-error
45744574
addIntoResults(results_in_args, row.id, i, -1, tfpDist, 0, maxDist);
45754575
}
45764576
if (returned) {
4577-
// @ts-expect-error
45784577
results_returned.max_dist = Math.max(
4579-
// @ts-expect-error
45804578
results_returned.max_dist || 0,
45814579
tfpDist,
45824580
);
45834581
const maxDist = results_returned.size < MAX_RESULTS ?
45844582
(tfpDist + 1) :
4585-
// @ts-expect-error
45864583
results_returned.max_dist;
45874584
// @ts-expect-error
45884585
addIntoResults(results_returned, row.id, i, -1, tfpDist, 0, maxDist);

0 commit comments

Comments
 (0)