Skip to content

Commit 1b4778d

Browse files
committed
Handle code block with indented escapce character
1 parent a70213b commit 1b4778d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/comment.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,16 @@ fn hide_sharp_behind_comment<'a>(s: &'a str) -> Cow<'a, str> {
505505
}
506506
}
507507

508-
fn trim_custom_comment_prefix(s: String) -> String {
508+
fn trim_custom_comment_prefix(s: &str) -> String {
509509
s.lines()
510-
.map(|line| line.trim_left_matches(RUSTFMT_CUSTOM_COMMENT_PREFIX))
510+
.map(|line| {
511+
let left_trimmed = line.trim_left();
512+
if left_trimmed.starts_with(RUSTFMT_CUSTOM_COMMENT_PREFIX) {
513+
left_trimmed.trim_left_matches(RUSTFMT_CUSTOM_COMMENT_PREFIX)
514+
} else {
515+
line
516+
}
517+
})
511518
.collect::<Vec<_>>()
512519
.join("\n")
513520
}

0 commit comments

Comments
 (0)