about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2019-05-21 14:49:53 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2019-05-21 14:49:53 +0200
commit8ca388743927547a23e512ecccb66d87ab024043 (patch)
treef826628278baa2ddf741e249a8e8d7be4b3f9c64
parent589beb979c0f1a9736e02e578913db88398c3ba5 (diff)
downloadrust-8ca388743927547a23e512ecccb66d87ab024043.tar.gz
rust-8ca388743927547a23e512ecccb66d87ab024043.zip
Fix lines highlighting in rustdoc source view
-rw-r--r--src/librustdoc/html/static/main.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 72a01a49bc6..82d2c11b249 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -162,8 +162,15 @@ if (!DOMTokenList.prototype.remove) {
         var i, from, to, match = window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);
         if (match) {
             from = parseInt(match[1], 10);
-            to = Math.min(50000, parseInt(match[2] || match[1], 10));
-            from = Math.min(from, to);
+            to = from;
+            if (typeof match[2] !== "undefined") {
+                to = parseInt(match[2], 10);
+            }
+            if (to < from) {
+                var tmp = to;
+                to = from;
+                from = tmp;
+            }
             elem = document.getElementById(from);
             if (!elem) {
                 return;
@@ -180,7 +187,11 @@ if (!DOMTokenList.prototype.remove) {
                 });
             });
             for (i = from; i <= to; ++i) {
-                addClass(document.getElementById(i), "line-highlighted");
+                elem = document.getElementById(i);
+                if (!elem) {
+                    break;
+                }
+                addClass(elem, "line-highlighted");
             }
         } else if (ev !== null && search && !hasClass(search, "hidden") && ev.newURL) {
             addClass(search, "hidden");