Skip to content

Commit 0bd7d81

Browse files
committed
Fix comment prefix method for four slash comments
1 parent b6560e3 commit 0bd7d81

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

crates/ra_syntax/src/ast/tokens.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ impl Comment {
1313
}
1414

1515
pub fn prefix(&self) -> &'static str {
16-
prefix_by_kind(self.kind())
16+
for (prefix, k) in COMMENT_PREFIX_TO_KIND.iter() {
17+
if *k == self.kind() && self.text().starts_with(prefix) {
18+
return prefix;
19+
}
20+
}
21+
unreachable!()
1722
}
1823
}
1924

@@ -70,15 +75,6 @@ fn kind_by_prefix(text: &str) -> CommentKind {
7075
panic!("bad comment text: {:?}", text)
7176
}
7277

73-
fn prefix_by_kind(kind: CommentKind) -> &'static str {
74-
for (prefix, k) in COMMENT_PREFIX_TO_KIND.iter() {
75-
if *k == kind {
76-
return prefix;
77-
}
78-
}
79-
unreachable!()
80-
}
81-
8278
impl Whitespace {
8379
pub fn spans_multiple_lines(&self) -> bool {
8480
let text = self.text();

0 commit comments

Comments
 (0)