File tree 2 files changed +15
-0
lines changed
src/librustdoc/html/static/js
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1393,6 +1393,7 @@ function initSearch(rawSearchIndex) {
1393
1393
*/
1394
1394
async function sortResults ( results , isType , preferredCrate ) {
1395
1395
const userQuery = parsedQuery . userQuery ;
1396
+ const casedUserQuery = parsedQuery . original ;
1396
1397
const result_list = [ ] ;
1397
1398
for ( const result of results . values ( ) ) {
1398
1399
result . item = searchIndex [ result . id ] ;
@@ -1403,6 +1404,13 @@ function initSearch(rawSearchIndex) {
1403
1404
result_list . sort ( ( aaa , bbb ) => {
1404
1405
let a , b ;
1405
1406
1407
+ // sort by exact case-sensitive match
1408
+ a = ( aaa . item . name !== casedUserQuery ) ;
1409
+ b = ( bbb . item . name !== casedUserQuery ) ;
1410
+ if ( a !== b ) {
1411
+ return a - b ;
1412
+ }
1413
+
1406
1414
// sort by exact match with regard to the last word (mismatch goes later)
1407
1415
a = ( aaa . word !== userQuery ) ;
1408
1416
b = ( bbb . word !== userQuery ) ;
Original file line number Diff line number Diff line change
1
+ const EXPECTED = {
2
+ 'query' : 'Aaa' ,
3
+ 'others' : [
4
+ { 'path' : 'std::marker::Copy' } ,
5
+ { 'path' : 'std::fs::copy' } ,
6
+ ] ,
7
+ }
You can’t perform that action at this time.
0 commit comments