File tree Expand file tree Collapse file tree 1 file changed +6
-24
lines changed
crates/oxc_formatter/src/formatter/printer Expand file tree Collapse file tree 1 file changed +6
-24
lines changed Original file line number Diff line number Diff line change @@ -594,36 +594,18 @@ impl<'a> Printer<'a> {
594594 if !self . state . pending_indent . is_empty ( ) {
595595 let indent = std:: mem:: take ( & mut self . state . pending_indent ) ;
596596
597- match self . options . indent_style ( ) {
598- IndentStyle :: Tab => {
599- for _ in 0 ..indent. level ( ) {
600- // SAFETY: `'\t'` is an valid ASCII character
601- unsafe {
602- self . state . buffer . print_byte_unchecked ( b'\t' ) ;
603- }
604- self . state . line_width += self . options . indent_width ( ) . value ( ) as usize ;
605- }
606- }
607- IndentStyle :: Space => {
608- #[ expect( clippy:: cast_lossless) ]
609- let total = indent. level ( ) * self . options . indent_width ( ) . value ( ) as u16 ;
610- for _ in 0 ..total {
611- // SAFETY: `' '` is an valid ASCII character
612- unsafe {
613- self . state . buffer . print_byte_unchecked ( b' ' ) ;
614- }
615- self . state . line_width += 1 ;
616- }
617- }
618- }
597+ let level = indent. level ( ) as usize ;
598+ self . state . buffer . print_indent ( level) ;
599+ self . state . line_width += level * self . options . indent_width ( ) . value ( ) as usize ;
619600
620- for _ in 0 ..indent. align ( ) {
601+ let align_count = indent. align ( ) as usize ;
602+ for _ in 0 ..align_count {
621603 // SAFETY: `' '` is an valid ASCII character
622604 unsafe {
623605 self . state . buffer . print_byte_unchecked ( b' ' ) ;
624606 }
625- self . state . line_width += 1 ;
626607 }
608+ self . state . line_width += align_count;
627609 }
628610
629611 // Print pending spaces
You can’t perform that action at this time.
0 commit comments