Add aliases in the search as well

This commit is contained in:
Guillaume Gomez
2018-04-19 18:23:12 +02:00
parent 57bcabc108
commit 03b0856849
2 changed files with 20 additions and 6 deletions

View File

@@ -873,9 +873,13 @@ themePicker.onclick = function() {{
}
fn show_item(item: &IndexItem, krate: &str) -> String {
format!("{{'crate':'{}','ty':'{}','name':'{}','path':'{}','parent':{}}}",
krate, item.ty, item.name, item.path,
if let Some(p) = item.parent_idx { p.to_string() } else { "null".to_owned() })
format!("{{'crate':'{}','ty':{},'name':'{}','path':'{}'{}}}",
krate, item.ty as usize, item.name, item.path,
if let Some(p) = item.parent_idx {
format!(",'parent':{}", p)
} else {
String::new()
})
}
let dst = cx.dst.join("aliases.js");

View File

@@ -1012,11 +1012,21 @@
}
}
return {
var ret = {
'in_args': sortResults(results_in_args, true),
'returned': sortResults(results_returned, true),
'others': sortResults(results),
};
if (ALIASES[window.currentCrate][query.raw]) {
var aliases = ALIASES[window.currentCrate][query.raw];
for (var i = 0; i < aliases.length; ++i) {
ret['others'].unshift(aliases[i]);
if (ret['others'].length > MAX_RESULTS) {
ret['others'].pop();
}
}
}
return ret;
}
/**
@@ -1202,11 +1212,11 @@
array.forEach(function(item) {
var name, type, href, displayPath;
if (shown.indexOf(item) !== -1) {
if (shown.indexOf(item.ty) !== -1) {
return;
}
shown.push(item);
shown.push(item.ty);
name = item.name;
type = itemTypes[item.ty];