Skip to content

New configuration option: indent_blank_lines #6540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

quaternic
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants