diff --git a/crates/oxc_formatter/src/formatter/printer/call_stack.rs b/crates/oxc_formatter/src/formatter/printer/call_stack.rs index aa493dc903f8c..d186391fb2a33 100644 --- a/crates/oxc_formatter/src/formatter/printer/call_stack.rs +++ b/crates/oxc_formatter/src/formatter/printer/call_stack.rs @@ -299,6 +299,10 @@ impl<'print> FitsIndentStack<'print> { Self { indentions, history_indentions } } + + pub(super) fn finish(self) -> (Vec, Vec) { + (self.indentions.into_vec(), self.history_indentions.into_vec()) + } } impl<'a> IndentStack for FitsIndentStack<'a> { diff --git a/crates/oxc_formatter/src/formatter/printer/mod.rs b/crates/oxc_formatter/src/formatter/printer/mod.rs index f060f0cc469d2..70b27c93b4ae1 100644 --- a/crates/oxc_formatter/src/formatter/printer/mod.rs +++ b/crates/oxc_formatter/src/formatter/printer/mod.rs @@ -1203,6 +1203,12 @@ impl<'a, 'print> FitsMeasurer<'a, 'print> { let mut stack = self.stack.finish(); stack.clear(); self.printer.state.fits_stack = stack; + + let (mut indent_stack, mut history_stack) = self.indent_stack.finish(); + indent_stack.clear(); + self.printer.state.fits_indent_stack = indent_stack; + history_stack.clear(); + self.printer.state.fits_stack_tem_indent = history_stack; } fn options(&self) -> &PrinterOptions {