about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2018-04-19 18:23:12 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2018-04-21 22:02:53 +0200
commit03b0856849e625cde4418b403fb4bee7b7875c46 (patch)
tree7c3c08b229181641304545f63f5427096c4732ef
parent57bcabc1082c948e2cfda3f005c41d8236ead7a4 (diff)
downloadrust-03b0856849e625cde4418b403fb4bee7b7875c46.tar.gz
rust-03b0856849e625cde4418b403fb4bee7b7875c46.zip
Add aliases in the search as well
-rw-r--r--src/librustdoc/html/render.rs10
-rw-r--r--src/librustdoc/html/static/main.js16
2 files changed, 20 insertions, 6 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 8fe8fe671dd..09a11073a39 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -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");
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index fd8bd52cfab..c942eff6b02 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -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];