File tree 4 files changed +55
-4
lines changed
src/librustdoc/html/static/js
4 files changed +55
-4
lines changed Original file line number Diff line number Diff line change @@ -2098,6 +2098,7 @@ class DocSearch {
2098
2098
const sortResults = async ( results , isType , preferredCrate ) => {
2099
2099
const userQuery = parsedQuery . userQuery ;
2100
2100
const casedUserQuery = parsedQuery . original ;
2101
+ const isMixedCase = casedUserQuery !== userQuery ;
2101
2102
const result_list = [ ] ;
2102
2103
for ( const result of results . values ( ) ) {
2103
2104
result . item = this . searchIndex [ result . id ] ;
@@ -2109,10 +2110,12 @@ class DocSearch {
2109
2110
let a , b ;
2110
2111
2111
2112
// sort by exact case-sensitive match
2112
- a = ( aaa . item . name !== casedUserQuery ) ;
2113
- b = ( bbb . item . name !== casedUserQuery ) ;
2114
- if ( a !== b ) {
2115
- return a - b ;
2113
+ if ( isMixedCase ) {
2114
+ a = ( aaa . item . name !== casedUserQuery ) ;
2115
+ b = ( bbb . item . name !== casedUserQuery ) ;
2116
+ if ( a !== b ) {
2117
+ return a - b ;
2118
+ }
2116
2119
}
2117
2120
2118
2121
// sort by exact match with regard to the last word (mismatch goes later)
Original file line number Diff line number Diff line change
1
+ const EXPECTED = [
2
+ {
3
+ 'query' : 'write' ,
4
+ 'others' : [
5
+ { 'path' : 'std::fmt' , 'name' : 'write' } ,
6
+ { 'path' : 'std::fs' , 'name' : 'write' } ,
7
+ { 'path' : 'std::ptr' , 'name' : 'write' } ,
8
+ { 'path' : 'std::fmt' , 'name' : 'Write' } ,
9
+ { 'path' : 'std::io' , 'name' : 'Write' } ,
10
+ { 'path' : 'std::hash::Hasher' , 'name' : 'write' } ,
11
+ ] ,
12
+ } ,
13
+ {
14
+ 'query' : 'Write' ,
15
+ 'others' : [
16
+ { 'path' : 'std::fmt' , 'name' : 'Write' } ,
17
+ { 'path' : 'std::io' , 'name' : 'Write' } ,
18
+ { 'path' : 'std::fmt' , 'name' : 'write' } ,
19
+ { 'path' : 'std::fs' , 'name' : 'write' } ,
20
+ { 'path' : 'std::ptr' , 'name' : 'write' } ,
21
+ { 'path' : 'std::hash::Hasher' , 'name' : 'write' } ,
22
+ ] ,
23
+ } ,
24
+ ] ;
Original file line number Diff line number Diff line change
1
+ const EXPECTED = [
2
+ {
3
+ 'query' : 'Foo' ,
4
+ 'others' : [
5
+ { 'path' : 'case' , 'name' : 'Foo' , 'desc' : 'Docs for Foo' } ,
6
+ { 'path' : 'case' , 'name' : 'foo' , 'desc' : 'Docs for foo' } ,
7
+ ] ,
8
+ } ,
9
+ {
10
+ 'query' : 'foo' ,
11
+ 'others' : [
12
+ // https://github.com/rust-lang/rust/issues/133017
13
+ { 'path' : 'case' , 'name' : 'Foo' , 'desc' : 'Docs for Foo' } ,
14
+ { 'path' : 'case' , 'name' : 'foo' , 'desc' : 'Docs for foo' } ,
15
+ ] ,
16
+ } ,
17
+ ] ;
Original file line number Diff line number Diff line change
1
+ #![ allow( nonstandard_style) ]
2
+
3
+ /// Docs for Foo
4
+ pub struct Foo ;
5
+
6
+ /// Docs for foo
7
+ pub struct foo ;
You can’t perform that action at this time.
0 commit comments