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.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index 6ed1b5213..0c193e019 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -115,7 +115,7 @@ 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 `///` (+ optional 1 character of whitespace) 118 /// That is, strips leading `///` or trailing `*/` (+ optional 1 character of whitespace in either direction)
119 /// and joins lines. 119 /// and joins 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;
@@ -136,7 +136,18 @@ pub trait DocCommentsOwner: AstNode {
136 prefix_len 136 prefix_len
137 }; 137 };
138 138
139 line[pos..].to_owned() 139 let end = if comment.kind().shape.is_block() && line.ends_with("*/") {
140 // FIXME: Use `nth_back` here once stable
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 {
147 line.len()
148 };
149
150 line[pos..end].to_owned()
140 }) 151 })
141 .join("\n"); 152 .join("\n");
142 153