Skip to content

New configuration option: indent_blank_lines#6540

Open
quaternic wants to merge 5 commits into
rust-lang:mainfrom
quaternic:indent_blank_lines
Open

New configuration option: indent_blank_lines#6540
quaternic wants to merge 5 commits into
rust-lang:mainfrom
quaternic:indent_blank_lines

Conversation

@quaternic
Copy link
Copy Markdown

Implements a new configuration option,indent_blank_lines, to indent empty lines left between items.

Relevant issue: #887
Important difference: This makes no attempt to preserve the original (horizontal) whitespace on that line; the line is simply indented with the indent of the containing block.

Note: Reviewing each commit individually is highly recommended.

  1. The first commit streamlines the logic in the key function without changing behavior.
  2. The second fixes some edge cases that are likely not actually possible, and reorganizes the logic in preparation for the third.
  3. The third commit actually implements the configuration flag. The mechanism is the same that is used for blank_lines_{lower/upper}_bound.
  4. The fourth adds a bypass to inhibit the internal error for trailing whitespace when the line in question is only whitespace. Ideally this could be made stricter by requiring that it actually is properly indented, but I didn't see any obvious ways to do that at that point in the code.
  5. The last commit adds a basic test for the functionality. These probably should be expanded to include some relevant combinations with other configurations like hard_tabs.

Known issues

Empty lines between match-arms or where-bounds ignore this setting, and are left unindented. I have not looked into it much further, but blank_lines_{lower/upper}_bound already had the same problem so it is not unexpected.

@quaternic quaternic changed the title Indent blank lines New configuration option: indent_blank_lines Apr 14, 2025
@jieyouxu jieyouxu added S-waiting-on-review Status: awaiting review from the assignee but also interested parties. and removed pr-not-reviewed labels Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants