Skip to content

Commit f00d72b

Browse files
Seldaekalexcrichton
authored andcommitted
Make source links highlight the entire definition and not just the first line
1 parent 49e6db7 commit f00d72b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/librustdoc/html/render.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,13 +714,18 @@ impl<'self> fmt::Default for Item<'self> {
714714
do clean_srcpath(it.item.source.filename) |component| {
715715
path.push(component.to_owned());
716716
}
717+
let href = if it.item.source.loline == it.item.source.hiline {
718+
format!("{}", it.item.source.loline)
719+
} else {
720+
format!("{}-{}", it.item.source.loline, it.item.source.hiline)
721+
};
717722
write!(fmt.buf,
718723
"<a class='source'
719-
href='{root}src/{crate}/{path}.html\\#{line}'>[src]</a>",
724+
href='{root}src/{crate}/{path}.html\\#{href}'>[src]</a>",
720725
root = it.cx.root_path,
721726
crate = it.cx.layout.crate,
722727
path = path.connect("/"),
723-
line = it.item.source.loline);
728+
href = href);
724729
}
725730

726731
// Write the breadcrumb trail header for the top

0 commit comments

Comments
 (0)