fn fix_comment_indentation(
    token: &SyntaxToken,
    model: &mut FmtModel,
    anchor_set: &PatternSet<&Pattern>,
) {
    let is_block_comment = token.text().starts_with("/*");
    let normal_indent = match indent_anchor(&token.clone().into(), model, anchor_set) {
        None => return,
        Some((_element, indent)) => indent,
    };
    let block = model.block_for(&token.clone().into(), BlockPosition::Before);
    if !is_block_comment {
        single_line_comment_indent(token, model, anchor_set);
        return;
    }

    let comment_indent = {
        if block.text().contains('\n') {
            IndentLevel::from_whitespace_block(block.text())
        } else {
            normal_indent
        }
    };

    let content_indent = comment_indent.indent();
    let mut curr_offset = token.text_range().start();
    let mut first = true;
    for line in token.text().lines() {
        let offset = curr_offset;
        curr_offset += TextSize::of(line) + TextSize::of('\n');
        if first {
            first = false;
            continue;
        }
        let last_line_only_end_block = line.ends_with("*/") || line.trim_start() == "*/";
        let start_with_asterisk = line.trim_start().starts_with("*");
        let current_indent = IndentLevel::get_whitespace_block(line);
        if let Some(ws_end) = line.find(|it| it != ' ') {
            let delete =
                TextRange::at(offset, TextSize::try_from(ws_end).expect("woah big number"));
            if last_line_only_end_block || start_with_asterisk {
                model.raw_edit(AtomEdit {
                    delete,
                    insert: comment_indent.add_alignment(current_indent).into(),
                })
            } else {
                model.raw_edit(AtomEdit {
                    delete,
                    insert: content_indent.adjust_alignment(current_indent).into(),
                })
            }
        }
    }
}
/// If we indent multiline block comment, we should indent it's content as well.
If we indent multiline block comment, we should indent it's content as well.
If we indent multiline block comment we should indent it ' s content as well .
fn fix_comment_indentation(
    token: &SyntaxToken,
    model: &mut FmtModel,
    anchor_set: &PatternSet<&Pattern>,
) {
    let is_block_comment = token.text().starts_with("/*");
    let normal_indent = match indent_anchor(&token.clone().into(), model, anchor_set) {
        None => return,
        Some((_element, indent)) => indent,
    };
    let block = model.block_for(&token.clone().into(), BlockPosition::Before);
    if !is_block_comment {
        single_line_comment_indent(token, model, anchor_set);
        return;
    }
    let comment_indent = {
        if block.text().contains('\n') {
            IndentLevel::from_whitespace_block(block.text())
        } else {
            normal_indent
        }
    };
    let content_indent = comment_indent.indent();
    let mut curr_offset = token.text_range().start();
    let mut first = true;
    for line in token.text().lines() {
        let offset = curr_offset;
        curr_offset += TextSize::of(line) + TextSize::of('\n');
        if first {
            first = false;
            continue;
        }
        let last_line_only_end_block = line.ends_with("*/") || line.trim_start() == "*/";
        let start_with_asterisk = line.trim_start().starts_with("*");
        let current_indent = IndentLevel::get_whitespace_block(line);
        if let Some(ws_end) = line.find(|it| it != ' ') {
            let delete =
                TextRange::at(offset, TextSize::try_from(ws_end).expect("woah big number"));
            if last_line_only_end_block || start_with_asterisk {
                model.raw_edit(AtomEdit {
                    delete,
                    insert: comment_indent.add_alignment(current_indent).into(),
                })
            } else {
                model.raw_edit(AtomEdit {
                    delete,
                    insert: content_indent.adjust_alignment(current_indent).into(),
                })
            }
        }
    }
}
fn fix_comment_indentation ( token : & SyntaxToken , model : & mut FmtModel , anchor_set : & PatternSet < & Pattern > , ) { let is_block_comment = token . text ( ) . starts_with ( " " ) ; let normal_indent = match indent_anchor ( & token . clone ( ) . into ( ) , model , anchor_set ) { None => return , Some ( ( _element , indent ) ) => indent , } ; let block = model . block_for ( & token . clone ( ) . into ( ) , BlockPosition :: Before ) ; if ! is_block_comment { single_line_comment_indent ( token , model , anchor_set ) ; return ; } let comment_indent = { if block . text ( ) . contains ( '\n' ) { IndentLevel :: from_whitespace_block ( block . text ( ) ) } else { normal_indent } } ; let content_indent = comment_indent . indent ( ) ; let mut curr_offset = token . text_range ( ) . start ( ) ; let mut first = true ; for line in token . text ( ) . lines ( ) { let offset = curr_offset ; curr_offset += TextSize :: of ( line ) + TextSize :: of ( '\n' ) ; if first { first = false ; continue ; } let last_line_only_end_block = line . ends_with ( " " ) || line . trim_start ( ) == " " ; let start_with_asterisk = line . trim_start ( ) . starts_with ( " " ) ; let current_indent = IndentLevel :: get_whitespace_block ( line ) ; if let Some ( ws_end ) = line . find ( | it | it != ' ' ) { let delete = TextRange :: at ( offset , TextSize :: try_from ( ws_end ) . expect ( " " ) ) ; if last_line_only_end_block || start_with_asterisk { model . raw_edit ( AtomEdit { delete , insert : comment_indent . add_alignment ( current_indent ) . into ( ) , } ) } else { model . raw_edit ( AtomEdit { delete , insert : content_indent . adjust_alignment ( current_indent ) . into ( ) , } ) } } } }
If we indent multiline block comment, we should indent it's content as well.
If we indent multiline block comment we should indent it ' s content as well .
token
&SyntaxToken
model
&mut FmtModel
anchor_set
&PatternSet<&Pattern>