Do not get tricked by a nested comment
This commit is contained in:
parent
f9f4ef8177
commit
95c7325ac2
1 changed files with 5 additions and 3 deletions
|
|
@ -572,10 +572,12 @@ where
|
|||
let comment_end = match self.inner.peek() {
|
||||
Some(..) => {
|
||||
let mut block_open_index = post_snippet.find("/*");
|
||||
// check if it really is a block comment (and not //*)
|
||||
// check if it really is a block comment (and not `//*` or a nested comment)
|
||||
if let Some(i) = block_open_index {
|
||||
if i > 0 && &post_snippet[i - 1..i] == "/" {
|
||||
block_open_index = None;
|
||||
match post_snippet.find("/") {
|
||||
Some(j) if j < i => block_open_index = None,
|
||||
_ if i > 0 && &post_snippet[i - 1..i] == "/" => block_open_index = None,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
let newline_index = post_snippet.find('\n');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue