diff options
author | Jeremy Kolb <[email protected]> | 2019-10-27 20:56:25 +0000 |
---|---|---|
committer | Jeremy Kolb <[email protected]> | 2019-10-27 20:56:25 +0000 |
commit | 1438f38eb63e5a79350fa6c877d9960ab90e183d (patch) | |
tree | 68ad8a4f944b82c2e17811f41948dc3cd5b345fd /crates/ra_syntax/src/ast | |
parent | 46b63c462d66925b59c0af7dec2eb3c48bc7be25 (diff) |
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
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/traits.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index f275a4955..76313684e 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs | |||
@@ -120,7 +120,7 @@ pub trait DocCommentsOwner: AstNode { | |||
120 | has_comments = true; | 120 | has_comments = true; |
121 | let prefix_len = comment.prefix().len(); | 121 | let prefix_len = comment.prefix().len(); |
122 | 122 | ||
123 | let line = comment.text().as_str(); | 123 | let line: &str = comment.text().as_str(); |
124 | 124 | ||
125 | // Determine if the prefix or prefix + 1 char is stripped | 125 | // Determine if the prefix or prefix + 1 char is stripped |
126 | let pos = | 126 | let pos = |
@@ -136,7 +136,10 @@ pub trait DocCommentsOwner: AstNode { | |||
136 | line.len() | 136 | line.len() |
137 | }; | 137 | }; |
138 | 138 | ||
139 | line[pos..end].trim_end().to_owned() | 139 | // Note that we do not trim the end of the line here |
140 | // since whitespace can have special meaning at the end | ||
141 | // of a line in markdown. | ||
142 | line[pos..end].to_owned() | ||
140 | }) | 143 | }) |
141 | .join("\n"); | 144 | .join("\n"); |
142 | 145 | ||