Skip to content

fix(codegen): clear print_next_indent_as_space after newlines#17884

Closed
s7tya wants to merge 1 commit intooxc-project:mainfrom
s7tya:clear-indent-space-flag-on-newline
Closed

fix(codegen): clear print_next_indent_as_space after newlines#17884
s7tya wants to merge 1 commit intooxc-project:mainfrom
s7tya:clear-indent-space-flag-on-newline

Conversation

@s7tya
Copy link
Contributor

@s7tya s7tya commented Jan 11, 2026

print_comments() can set print_next_indent_as_space after inline comments to request a single space before the next token. If a newline is emitted before the flag is consumed, the flag may leak across line boundaries and get consumed at the start of the next statement, producing stray leading spaces.

This PR clears print_next_indent_as_space whenever a newline is emitted (print_soft_newline / print_hard_newline) and routes print_semicolon_after_statement() through print_hard_newline() so newline handling consistently resets the flag.

@github-actions github-actions bot added A-codegen Area - Code Generation C-bug Category - Bug labels Jan 11, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 11, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing s7tya:clear-indent-space-flag-on-newline (da113bb) with main (9e89389)1

Summary

✅ 42 untouched benchmarks
⏩ 3 skipped benchmarks2

Footnotes

  1. No successful run was found on main (62b7a01) during the generation of this report, so 9e89389 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Jan 12, 2026
@graphite-app
Copy link
Contributor

graphite-app bot commented Jan 12, 2026

Merge activity

  • Jan 12, 2:27 AM UTC: @s7tya we removed the merge queue label because we could not find a Graphite account associated with your GitHub profile.

You must have a Graphite account in order to use the merge queue. Create an account and try again using this link

@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 12, 2026
@Dunqing Dunqing force-pushed the clear-indent-space-flag-on-newline branch from 042f0f6 to da113bb Compare January 12, 2026 02:36
@Boshen Boshen self-assigned this Jan 12, 2026
Copy link
Member

@Boshen Boshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix doesn't look right, let me double check.

@Boshen Boshen marked this pull request as draft January 12, 2026 02:44
Boshen added a commit that referenced this pull request Jan 14, 2026
…comments

Clear the `print_next_indent_as_space` flag after printing comments in
`ExportSpecifier` to prevent it from leaking to subsequent statements.

When a block comment like `/* comment */` is printed inside an export
specifier, the flag is set expecting `print_indent()` to consume it.
However, `ExportSpecifier` calls `print_soft_space()` instead, leaving
the flag set. This caused the next export statement to incorrectly
print a leading space.

Closes #17884

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@graphite-app graphite-app bot closed this in 2619c66 Jan 14, 2026
@s7tya s7tya deleted the clear-indent-space-flag-on-newline branch January 14, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-codegen Area - Code Generation C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants