We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a70213b commit 1b4778dCopy full SHA for 1b4778d
src/comment.rs
@@ -505,9 +505,16 @@ fn hide_sharp_behind_comment<'a>(s: &'a str) -> Cow<'a, str> {
505
}
506
507
508
-fn trim_custom_comment_prefix(s: String) -> String {
+fn trim_custom_comment_prefix(s: &str) -> String {
509
s.lines()
510
- .map(|line| line.trim_left_matches(RUSTFMT_CUSTOM_COMMENT_PREFIX))
+ .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
+ })
518
.collect::<Vec<_>>()
519
.join("\n")
520
0 commit comments