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 cf2e4fb commit a0875edCopy full SHA for a0875ed
crates/fmt/src/state/mod.rs
@@ -599,8 +599,13 @@ impl<'sess> State<'sess, '_> {
599
// Doc comments preserve leading whitespaces (right after the prefix).
600
self.word(prefix);
601
let content = &line[prefix.len()..];
602
- let (leading_ws, rest) =
603
- content.split_at(content.chars().take_while(|&c| c.is_whitespace()).count());
+ let (leading_ws, rest) = content.split_at(
+ content
604
+ .char_indices()
605
+ .take_while(|(_, c)| c.is_whitespace())
606
+ .last()
607
+ .map_or(0, |(idx, c)| idx + c.len_utf8()),
608
+ );
609
if !leading_ws.is_empty() {
610
self.word(leading_ws.to_owned());
611
}
0 commit comments