Skip to content

Commit bfd01b7

Browse files
rustdoc: move the space at the end of where clauses
...so that we don't indent the next line by one extra space
1 parent ae0e45c commit bfd01b7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/librustdoc/html/format.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,23 @@ impl<'a> fmt::Display for WhereClause<'a> {
237237
clause.push(',');
238238
}
239239
}
240+
241+
if end_newline {
242+
//add a space so stripping <br> tags and breaking spaces still renders properly
243+
if f.alternate() {
244+
clause.push(' ');
245+
} else {
246+
clause.push_str("&nbsp;");
247+
}
248+
}
249+
240250
if !f.alternate() {
241251
clause.push_str("</span>");
242252
let padding = repeat("&nbsp;").take(indent + 4).collect::<String>();
243253
clause = clause.replace("<br>", &format!("<br>{}", padding));
244254
clause.insert_str(0, &repeat("&nbsp;").take(indent.saturating_sub(1))
245255
.collect::<String>());
246-
if end_newline {
247-
clause.push(' ');
248-
} else {
256+
if !end_newline {
249257
clause.insert_str(0, "<br>");
250258
}
251259
}

0 commit comments

Comments
 (0)