Repository navigation
Add opt-in formatter options for blank lines - #65455
Open
Rafael Molina (rafamolina1) wants to merge 1 commit into
Open
Rafael Molina (rafamolina1) wants to merge 1 commit into
Rafael Molina (rafamolina1) wants to merge 1 commit into
Conversation
Author
|
@microsoft-github-policy-service agree |
Rafael Molina (rafamolina1)
marked this pull request as ready for review
November 12, 2026 18:26
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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;0removes 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:
internal/format,internal/ls/lsutil, andinternal/ls.gofmtandgit 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
Backlogmilestone. Full repository validation (validate --all, full tests, lint, andcheck: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.