rustfmt
rustfmt copied to clipboard
New configuration option: indent_blank_lines
Implements a new configuration option,indent_blank_lines, to indent empty lines left between items.
Relevant issue: https://github.com/rust-lang/rustfmt/issues/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.
- The first commit streamlines the logic in the key function without changing behavior.
- The second fixes some edge cases that are likely not actually possible, and reorganizes the logic in preparation for the third.
- The third commit actually implements the configuration flag. The mechanism is the same that is used for
blank_lines_{lower/upper}_bound. - 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.
- 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.