Skip to content

Commit be6c7cf

Browse files
committed
auto merge of rust-lang#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/)
2 parents 4ed40ff + 1d784d4 commit be6c7cf

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/librustdoc/html/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ r##"<!DOCTYPE html>
106106
</p>
107107
<p>
108108
Accepted types are: <code>fn</code>, <code>mod</code>,
109-
<code>struct</code> (or <code>str</code>), <code>enum</code>,
109+
<code>struct</code>, <code>enum</code>,
110110
<code>trait</code>, <code>typedef</code> (or
111111
<code>tdef</code>).
112112
</p>

src/librustdoc/html/static/main.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,18 +368,19 @@
368368
}
369369

370370
function getQuery() {
371-
var matches, type, query = $('.search-input').val();
371+
var matches, type, query, raw = $('.search-input').val();
372+
query = raw;
372373

373-
matches = query.match(/^(fn|mod|str(uct)?|enum|trait|t(ype)?d(ef)?)\s*:\s*/i);
374+
matches = query.match(/^(fn|mod|struct|enum|trait|t(ype)?d(ef)?)\s*:\s*/i);
374375
if (matches) {
375376
type = matches[1].replace(/^td$/, 'typedef')
376-
.replace(/^str$/, 'struct')
377377
.replace(/^tdef$/, 'typedef')
378378
.replace(/^typed$/, 'typedef');
379379
query = query.substring(matches[0].length);
380380
}
381381

382382
return {
383+
raw: raw,
383384
query: query,
384385
type: type,
385386
id: query + type,
@@ -535,10 +536,10 @@
535536
if (browserSupportsHistoryApi()) {
536537
if (!history.state && !params.search) {
537538
history.pushState(query, "", "?search=" +
538-
encodeURIComponent(query.query));
539+
encodeURIComponent(query.raw));
539540
} else {
540541
history.replaceState(query, "", "?search=" +
541-
encodeURIComponent(query.query));
542+
encodeURIComponent(query.raw));
542543
}
543544
}
544545

0 commit comments

Comments
 (0)