Skip to content

Add opt-in formatter options for blank lines - #65455

Open
Rafael Molina (rafamolina1) wants to merge 1 commit into
microsoft:mainfrom
rafamolina1:feat/formatter-blank-lines
Open

Rafael Molina (rafamolina1) wants to merge 1 commit into
microsoft:mainfrom
rafamolina1:feat/formatter-blank-lines

Conversation

@rafamolina1

Copy link
Copy Markdown

Fixes #65453.

The native formatter currently preserves redundant blank lines. This adds two opt-in formatting preferences while keeping the existing output unchanged by default:

  • removeBlankLinesBeforeClosingBrace: removes blank lines before structural closing braces, preserving a line break and indentation.
  • maxConsecutiveBlankLines: limits blank lines between tokens and comments; 0 removes all blank lines. An omitted limit preserves existing blank lines.

The preferences flow through the existing language-server configuration and generated Go/TypeScript interfaces. Optional integer parsing distinguishes an absent limit from zero and rejects fractional, negative, or overflowing configuration values.

Cleanup uses scanner ranges and coordinates with existing spacing and indentation edits. It respects selection and content-mapper boundaries, preserves literal/comment contents, and leaves on-type formatting and file-leading/trailing blank lines unchanged. The closing-brace preference excludes template interpolations and JSX expressions.

Validation

Passed with one build worker, serial tests, and low CPU/I/O priority:

  • Complete unit tests for internal/format, internal/ls/lsutil, and internal/ls.
  • Preference generator tests, plus verification that generated Go and TypeScript definitions are current.
  • Focused fourslash integration tests for document formatting and mapped verbatim ranges.
  • gofmt and git diff --check.

Regression cases cover limits 0/1/2, unchanged defaults, option precedence, LF/CRLF, comments, templates, JSX, ASI, syntax errors, selections, non-overlapping edits, idempotence, and configuration round trips.

Draft status

The issue has not yet been assigned to the required Backlog milestone. Full repository validation (validate --all, full tests, lint, and check:format) remains pending; focused validation was used to avoid overloading the local machine.

AI assistance

The implementation and regression tests were authored with OpenAI Codex.

@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 12, 2026
@rafamolina1

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@rafamolina1
Rafael Molina (rafamolina1) marked this pull request as ready for review November 12, 2026 18:26
Copilot AI balanced review requested due to automatic review settings November 12, 2026 18:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Formatter] add new options for blank lines

2 participants

Sponsor
SponsoredKunjungi sekarang
Promo