-
Notifications
You must be signed in to change notification settings - Fork 900
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
[Feature-Request] Blank-lines surrounding curly braces #5963
Comments
Thanks for reaching out. If I understand correctly, you'd like an option to enforce a consistent number of blank lines between various control flow constructs. Let me know if I've got that right. Reading the Contributing.md doc should give you a rough overview of how rustfmt works, how to go about adding tests, and also how to add new configuration options. I can't say how easy or difficult it would be to implement such a feature, but I can try to provide some guidance if you decide to get started. I also want to be upfront and say that this is a fairly low priority feature request so it's unlikely that the rustfmt team would work on this directly, but PRs are welcome. Assuming the new configuration option doesn't add too much complexity to the codebase we might consider adding it. |
Thanks @ytmimi, but how dare you put that Kidding! Of course, this is low priority haha. Any chance you could give some more guidance on where to get started? My inkling is that it'll be something to do with If the problem is a maze, I'm just looking for you to show me the entrance, and I'll see if I can make my way to the exit. Thanks in advance! |
You might want to familiarize yourself with how functions get rewritten. That starts in Some advice; Be generous with To build and run your local version of rustfmt run fn main() {
for i in 1.. {
println!("{i}");
}
} All together you can run your local rustfmt like this:
|
Thanks @ytmimi, I have a pretty good idea of what I need to do |
Sorry if this is a dup, I searched for a little bit and only found issues related to blank lines inside curly braces.
I have no idea how hard this would be, but it would be really nice to have a configurable option to add blank lines surrounding anything with curly braces.
with the rule on
with the rule off
This would include
for-loop
,loop
,while
, etc. Any expressions with a scope defined by curly braces.I'm thinking something akin to this rule: https://eslint.org/docs/latest/rules/padding-line-between-statements
I'm trying to have some automatic way to not get code that looks like this:
and have the formatted add some empty lines to make the code easier to read
Obviously, not everyone wants this, but it would be great if it were an option. I'm happy to PR, if someone can point me in the right direction.
The text was updated successfully, but these errors were encountered: