mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Preserve whitespace at the end of doc comments
Whitespace can have special meaning in markdown. For instance ending a line with three spaces will render a new line. Note that this behavior diverges from RLS. Fixes #1997
This commit is contained in:
parent
46b63c462d
commit
1438f38eb6
2 changed files with 27 additions and 4 deletions
|
@ -120,7 +120,7 @@ pub trait DocCommentsOwner: AstNode {
|
|||
has_comments = true;
|
||||
let prefix_len = comment.prefix().len();
|
||||
|
||||
let line = comment.text().as_str();
|
||||
let line: &str = comment.text().as_str();
|
||||
|
||||
// Determine if the prefix or prefix + 1 char is stripped
|
||||
let pos =
|
||||
|
@ -136,7 +136,10 @@ pub trait DocCommentsOwner: AstNode {
|
|||
line.len()
|
||||
};
|
||||
|
||||
line[pos..end].trim_end().to_owned()
|
||||
// Note that we do not trim the end of the line here
|
||||
// since whitespace can have special meaning at the end
|
||||
// of a line in markdown.
|
||||
line[pos..end].to_owned()
|
||||
})
|
||||
.join("\n");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue