File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
src/librustdoc/html/static/js Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff 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 { ┊
@@ -264,6 +264,7 @@ declare namespace rustdoc {
264264 displayTypeSignature : Promise < rustdoc . DisplayTypeSignature > | null ,
265265 item : Row ,
266266 dontValidate ?: boolean ,
267+ alias ?: string ,
267268 }
268269
269270 /**
Original file line number Diff line number Diff line change @@ -4273,7 +4273,11 @@ class DocSearch {
42734273 } ;
42744274 }
42754275
4276- // @ts -expect-error
4276+ /**
4277+ * Handle searching by doc aliases
4278+ *
4279+ * @type {function(rustdoc.ResultsTable, string, Object=, Object=): Promise<void> }
4280+ */
42774281 const handleAliases = async ( ret , query , filterCrates , currentCrate ) => {
42784282 const lowerQuery = query . toLowerCase ( ) ;
42794283 // We separate aliases and crate aliases because we want to have current crate
@@ -4328,15 +4332,20 @@ class DocSearch {
43284332 Promise . all ( aliases . map ( fetchDesc ) ) ,
43294333 ] ) ;
43304334
4335+ // if there are any existing results that match exactly, those go before aliases.
4336+ let exactMatches = 0 ;
4337+ while ( ret . others [ exactMatches ] !== undefined && ret . others [ exactMatches ] . dist === 0 ) {
4338+ exactMatches += 1 ;
4339+ }
4340+
43314341 // @ts -expect-error
43324342 const pushFunc = alias => {
43334343 alias . alias = query ;
43344344 const res = buildHrefAndPath ( alias ) ;
43354345 alias . displayPath = pathSplitter ( res [ 0 ] ) ;
43364346 alias . fullPath = alias . displayPath + alias . name ;
43374347 alias . href = res [ 1 ] ;
4338-
4339- ret . others . unshift ( alias ) ;
4348+ ret . others . splice ( exactMatches , 0 , alias ) ;
43404349 if ( ret . others . length > MAX_RESULTS ) {
43414350 ret . others . pop ( ) ;
43424351 }
You can’t perform that action at this time.
0 commit comments