Skip to content

Commit 95c7325

Browse files
committed
Do not get tricked by a nested comment
1 parent f9f4ef8 commit 95c7325

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/lists.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,12 @@ where
572572
let comment_end = match self.inner.peek() {
573573
Some(..) => {
574574
let mut block_open_index = post_snippet.find("/*");
575-
// check if it really is a block comment (and not //*)
575+
// check if it really is a block comment (and not `//*` or a nested comment)
576576
if let Some(i) = block_open_index {
577-
if i > 0 && &post_snippet[i - 1..i] == "/" {
578-
block_open_index = None;
577+
match post_snippet.find("/") {
578+
Some(j) if j < i => block_open_index = None,
579+
_ if i > 0 && &post_snippet[i - 1..i] == "/" => block_open_index = None,
580+
_ => (),
579581
}
580582
}
581583
let newline_index = post_snippet.find('\n');

0 commit comments

Comments
 (0)