auto merge of #16387 : Gankro/rust/doc-search, r=cmr
Fixes str/struct ambiguity (by removing the synonym) and pushes raw searches to the history instead of processed ones. # [Live Version Here](http://cg.scs.carleton.ca/~abeinges/doc/std/)
This commit is contained in:
commit
be6c7cf882
@ -106,7 +106,7 @@ r##"<!DOCTYPE html>
|
||||
</p>
|
||||
<p>
|
||||
Accepted types are: <code>fn</code>, <code>mod</code>,
|
||||
<code>struct</code> (or <code>str</code>), <code>enum</code>,
|
||||
<code>struct</code>, <code>enum</code>,
|
||||
<code>trait</code>, <code>typedef</code> (or
|
||||
<code>tdef</code>).
|
||||
</p>
|
||||
|
@ -368,18 +368,19 @@
|
||||
}
|
||||
|
||||
function getQuery() {
|
||||
var matches, type, query = $('.search-input').val();
|
||||
var matches, type, query, raw = $('.search-input').val();
|
||||
query = raw;
|
||||
|
||||
matches = query.match(/^(fn|mod|str(uct)?|enum|trait|t(ype)?d(ef)?)\s*:\s*/i);
|
||||
matches = query.match(/^(fn|mod|struct|enum|trait|t(ype)?d(ef)?)\s*:\s*/i);
|
||||
if (matches) {
|
||||
type = matches[1].replace(/^td$/, 'typedef')
|
||||
.replace(/^str$/, 'struct')
|
||||
.replace(/^tdef$/, 'typedef')
|
||||
.replace(/^typed$/, 'typedef');
|
||||
query = query.substring(matches[0].length);
|
||||
}
|
||||
|
||||
return {
|
||||
raw: raw,
|
||||
query: query,
|
||||
type: type,
|
||||
id: query + type,
|
||||
@ -535,10 +536,10 @@
|
||||
if (browserSupportsHistoryApi()) {
|
||||
if (!history.state && !params.search) {
|
||||
history.pushState(query, "", "?search=" +
|
||||
encodeURIComponent(query.query));
|
||||
encodeURIComponent(query.raw));
|
||||
} else {
|
||||
history.replaceState(query, "", "?search=" +
|
||||
encodeURIComponent(query.query));
|
||||
encodeURIComponent(query.raw));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user