File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -2089,6 +2089,7 @@ export default class DocSearchV2 {
2089
2089
*/
2090
2090
const sortResults = async ( results , isType , preferredCrate ) => {
2091
2091
const userQuery = parsedQuery . userQuery ;
2092
+ const casedUserQuery = parsedQuery . original ;
2092
2093
const result_list = [ ] ;
2093
2094
for ( const result of results . values ( ) ) {
2094
2095
result . item = this . searchIndex [ result . id ] ;
@@ -2099,6 +2100,13 @@ export default class DocSearchV2 {
2099
2100
result_list . sort ( ( aaa , bbb ) => {
2100
2101
let a , b ;
2101
2102
2103
+ // sort by exact case-sensitive match
2104
+ a = ( aaa . item . name !== casedUserQuery ) ;
2105
+ b = ( bbb . item . name !== casedUserQuery ) ;
2106
+ if ( a !== b ) {
2107
+ return a - b ;
2108
+ }
2109
+
2102
2110
// sort by exact match with regard to the last word (mismatch goes later)
2103
2111
a = ( aaa . word !== userQuery ) ;
2104
2112
b = ( bbb . word !== userQuery ) ;
You can’t perform that action at this time.
0 commit comments