Skip to content

Commit aec0a7c

Browse files
authored
Merge pull request rust-lang#3318 from rchaser53/issue-3314
fix Removed indentation after nested comments error
2 parents 81067b1 + 5fcb750 commit aec0a7c

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/comment.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ fn identify_comment(
321321
// for a block comment, search for the closing symbol
322322
CommentStyle::DoubleBullet | CommentStyle::SingleBullet | CommentStyle::Exclamation => {
323323
let closer = style.closer().trim_start();
324+
let mut count = orig.matches(closer).count();
324325
let mut closing_symbol_offset = 0;
325326
let mut hbl = false;
326327
let mut first = true;
@@ -341,7 +342,10 @@ fn identify_comment(
341342
first = false;
342343
}
343344
if trimmed_line.ends_with(closer) {
344-
break;
345+
count -= 1;
346+
if count == 0 {
347+
break;
348+
}
345349
}
346350
}
347351
(hbl, closing_symbol_offset)

tests/source/issue-3314.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*code
2+
/*code*/
3+
if true {
4+
println!("1");
5+
}*/

tests/target/issue-3314.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*code
2+
/*code*/
3+
if true {
4+
println!("1");
5+
}*/

0 commit comments

Comments
 (0)