Skip to content

Commit 99b30ba

Browse files
committed
Don't trim trailing whitespace from doc comments
Don't trim trailing whitespace from doc comments as multiple trailing spaces indicates a hard line break in Markdown.
1 parent 4e814e3 commit 99b30ba

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

crates/ide-db/src/documentation.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,13 @@ pub fn docs_from_attrs(attrs: &hir::Attrs) -> Option<String> {
138138
for doc in docs {
139139
// str::lines doesn't yield anything for the empty string
140140
if !doc.is_empty() {
141-
buf.extend(Itertools::intersperse(
142-
doc.lines().map(|line| {
143-
line.char_indices()
144-
.nth(indent)
145-
.map_or(line, |(offset, _)| &line[offset..])
146-
.trim_end()
147-
}),
148-
"\n",
149-
));
141+
// We don't trim trailing whitespace from doc comments as multiple trailing spaces
142+
// indicates a hard line break in Markdown.
143+
let lines = doc.lines().map(|line| {
144+
line.char_indices().nth(indent).map_or(line, |(offset, _)| &line[offset..])
145+
});
146+
147+
buf.extend(Itertools::intersperse(lines, "\n"));
150148
}
151149
buf.push('\n');
152150
}

0 commit comments

Comments
 (0)