diff --git a/crates/oxc_codegen/src/comment.rs b/crates/oxc_codegen/src/comment.rs index 98f81c03c86f2..799cd1a0c64d8 100644 --- a/crates/oxc_codegen/src/comment.rs +++ b/crates/oxc_codegen/src/comment.rs @@ -208,6 +208,8 @@ impl Codegen<'_> { match legal_comments { LegalComment::Eof => { self.print_hard_newline(); + // Clear the flag to ensure consistent formatting for all EOF comments + self.print_next_indent_as_space = false; for c in comments { self.print_comment(&c); self.print_hard_newline(); diff --git a/crates/oxc_codegen/tests/integration/snapshots/legal_eof_comments.snap b/crates/oxc_codegen/tests/integration/snapshots/legal_eof_comments.snap index 283b6bac4bd31..bf9cdd493815f 100644 --- a/crates/oxc_codegen/tests/integration/snapshots/legal_eof_comments.snap +++ b/crates/oxc_codegen/tests/integration/snapshots/legal_eof_comments.snap @@ -111,7 +111,7 @@ function foo() { * @preserve */ /** - * @preserve +* @preserve */ ########## 8