- }
-}
-
-/// Trims a minimum of leading whitespaces so that the content layout is kept and aligns to indent.
-fn light_rewrite_block_comment_with_bare_lines(
- orig: &str,
- shape: Shape,
- config: &Config,
-) -> Option<String> {
- let prefix_whitespace_min = orig
- .lines()
- // skip the line with the starting sigil since the leading whitespace is removed
- // otherwise, the minimum would always be zero
- .skip(1)
- .filter(|line| !line.is_empty())
- .map(|line| {
- let mut width = 0;
- for c in line.chars() {
- match c {
- ' ' => width += 1,
- '\t' => width += config.tab_spaces(),
- _ => break,
- }
- }
- width
- })
- .min()?;
-
- let indent_str = shape.indent.to_string(config);
- let mut lines = orig.lines();
- let first_line = lines.next()?;
- let rest = lines
- .map(|line| {
- if line.is_empty() {
- line
- } else {
- &line[prefix_whitespace_min..]
- }
+ .map(|rest_str| {
+ format!(
+ "{}\n{}{}{}",
+ rewritten_first_group,
+ // insert back the blank line
+ if has_bare_lines && style.is_line_comment() {
+ "\n"
+ } else {
+ ""
+ },
+ shape.indent.to_string(config),
+ rest_str
+ )