aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/traits.rs13
1 files changed, 4 insertions, 9 deletions
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index 0c193e019..1b9a2b20c 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -115,8 +115,8 @@ pub trait DocCommentsOwner: AstNode {
115 } 115 }
116 116
117 /// Returns the textual content of a doc comment block as a single string. 117 /// Returns the textual content of a doc comment block as a single string.
118 /// That is, strips leading `///` or trailing `*/` (+ optional 1 character of whitespace in either direction) 118 /// That is, strips leading `///` (+ optional 1 character of whitespace),
119 /// and joins lines. 119 /// trailing `*/`, trailing whitespace and then joins the lines.
120 fn doc_comment_text(&self) -> Option<String> { 120 fn doc_comment_text(&self) -> Option<String> {
121 let mut has_comments = false; 121 let mut has_comments = false;
122 let docs = self 122 let docs = self
@@ -137,17 +137,12 @@ pub trait DocCommentsOwner: AstNode {
137 }; 137 };
138 138
139 let end = if comment.kind().shape.is_block() && line.ends_with("*/") { 139 let end = if comment.kind().shape.is_block() && line.ends_with("*/") {
140 // FIXME: Use `nth_back` here once stable 140 line.len() - 2
141 if line.chars().rev().nth(2).map(|c| c.is_whitespace()).unwrap_or(false) {
142 line.len() - 3
143 } else {
144 line.len() - 2
145 }
146 } else { 141 } else {
147 line.len() 142 line.len()
148 }; 143 };
149 144
150 line[pos..end].to_owned() 145 line[pos..end].trim_end().to_owned()
151 }) 146 })
152 .join("\n"); 147 .join("\n");
153 148