Skip to content

Commit 2d01508

Browse files
authored
Rollup merge of rust-lang#110371 - notriddle:notriddle/search-corrections, r=GuillaumeGomez
rustdoc: restructure type search engine to pick-and-use IDs Fixes rust-lang#110029 Preview: https://notriddle.com/rustdoc-demo-html-3/search-corrections/std/index.html?search=-%3E%20streaming ![image](https://user-images.githubusercontent.com/1593513/233494900-ae77d5b4-e395-41f8-bbac-53ee55bb4a76.png) This change makes it so, instead of mixing string distance with type unification, function signature search works by mapping names to IDs at the start, reporting to the user any cases where it had to make corrections, and then matches with IDs when going through the items. This only changes function searches. Name searches are left alone, and corrections are only done when there's a single item in the search query.
2 parents e60067e + 395840c commit 2d01508

File tree

6 files changed

+361
-205
lines changed

6 files changed

+361
-205
lines changed

src/librustdoc/html/static/css/rustdoc.css

+4
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,10 @@ a.tooltip:hover::after {
12591259
background-color: var(--search-error-code-background-color);
12601260
}
12611261

1262+
.search-corrections {
1263+
font-weight: normal;
1264+
}
1265+
12621266
#src-sidebar-toggle {
12631267
position: sticky;
12641268
top: 0;

src/librustdoc/html/static/js/externs.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function initSearch(searchIndex){}
99
/**
1010
* @typedef {{
1111
* name: string,
12+
* id: integer,
1213
* fullPath: Array<string>,
1314
* pathWithoutLast: Array<string>,
1415
* pathLast: string,
@@ -36,6 +37,8 @@ let ParserState;
3637
* args: Array<QueryElement>,
3738
* returned: Array<QueryElement>,
3839
* foundElems: number,
40+
* literalSearch: boolean,
41+
* corrections: Array<{from: string, to: integer}>,
3942
* }}
4043
*/
4144
let ParsedQuery;
@@ -139,7 +142,7 @@ let FunctionSearchType;
139142

140143
/**
141144
* @typedef {{
142-
* name: (null|string),
145+
* id: (null|number),
143146
* ty: (null|number),
144147
* generics: Array<FunctionType>,
145148
* }}

0 commit comments

Comments
 (0)