rustdoc search: relax rules for identifiers
This commit is contained in:
@@ -149,7 +149,10 @@ const ROOT_PATH = typeof window !== "undefined" ? window.rootPath : "../";
|
||||
const UNBOXING_LIMIT = 5;
|
||||
|
||||
// used for search query verification
|
||||
const REGEX_IDENT = /\p{ID_Start}\p{ID_Continue}*|_\p{ID_Continue}+/uy;
|
||||
// because searches are often performed using substrings of identifiers,
|
||||
// and not just full identiferes, we allow them to start with chars that otherwise
|
||||
// can only appear in the middle of identifiers
|
||||
const REGEX_IDENT = /\p{ID_Continue}+/uy;
|
||||
const REGEX_INVALID_TYPE_FILTER = /[^a-z]/ui;
|
||||
|
||||
const MAX_RESULTS = 200;
|
||||
|
||||
@@ -165,7 +165,7 @@ const PARSED = [
|
||||
foundElems: 0,
|
||||
userQuery: "_:",
|
||||
returned: [],
|
||||
error: "Unexpected `_` (not a valid identifier)",
|
||||
error: "Unexpected `_` in type filter (before `:`)",
|
||||
},
|
||||
{
|
||||
query: "ab:",
|
||||
|
||||
19
tests/rustdoc-js-std/search-by-number.js
Normal file
19
tests/rustdoc-js-std/search-by-number.js
Normal file
@@ -0,0 +1,19 @@
|
||||
// regression test for https://github.com/rust-lang/rust/issues/147763
|
||||
//
|
||||
// identifiers in search queries should not be required to follow the
|
||||
// same strict rules around ID_Start that identifers in rust code follow,
|
||||
// as searches frequently use substrings of identifers.
|
||||
//
|
||||
// for example, identifiers cannot start with digits,
|
||||
// but they can contain them, so we allow search idents to start with digits.
|
||||
|
||||
const EXPECTED = {
|
||||
'query': '8',
|
||||
'others': [
|
||||
{
|
||||
'path': 'std',
|
||||
'name': 'i8',
|
||||
'href': '../std/primitive.i8.html',
|
||||
},
|
||||
]
|
||||
};
|
||||
Reference in New Issue
Block a user