diff options
| author | bors <bors@rust-lang.org> | 2019-06-03 00:02:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-06-03 00:02:34 +0000 |
| commit | 3a6bef0cbd01227bbcf593e8504164120a984fdc (patch) | |
| tree | fd192e7b7072ecdfa96910672ebc6e25829895cf | |
| parent | 607aadcb77e71e23a049bc37f7e480c1edaa3ea0 (diff) | |
| parent | 8ca388743927547a23e512ecccb66d87ab024043 (diff) | |
Auto merge of #61008 - GuillaumeGomez:fix-rustdoc-code-highlighting, r=Manishearth
Fix lines highlighting in rustdoc source view Fixes #60948. This PR fixes how we handle the lines highlighting from the URL (so in "/doc/src/alloc/string.rs.html#285-283", the "285-283" part). We got a hard limit on 50000, for some unknown and lost reasons which was used in case only one line is selected. r? @Manishearth
| -rw-r--r-- | src/librustdoc/html/static/main.js | 17 |
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"); |
