-
Notifications
You must be signed in to change notification settings - Fork 277
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
Adding Braces when maxline is below a certain limit #2019
Comments
@vito-c as i mentioned, the tool doesn't add braces. the rule is called redundant braces. maxLines simply specifies that larger code blocks should not be touched. in both cases, you are looking for the opposite of what the tool does. |
@kitbellew thanks! I will check this out when I have time :) |
I have something working on my local that adds braces when the body of a It would result in changing some of the output of the tests for example:
no longer produces this:
it now produces:
|
that's good to hear. one caveat: it must also work for
for that, the change must be in |
Is this the test case you are looking for?
|
Any tips here? |
if you do it in FormatWriter, you know where the formatter is putting the newlines. |
Yes, something like that. |
I've made some good progress on this but my lack of understanding on the FormatLocation is holding me back. I guess I'm not clear on how the For example:
Is how you would remove a after the I've gotten to the point where I can generate the string I want at this line. scalafmt/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatWriter.scala Line 113 in 8e9ce1c
and then I was hoping the Formatter would continue on it's way and finish formatting. But I think the way I used the |
Ok I am going to attempt to clean up what I have and create a pull request. Do you have anymore test cases I should add? @kitbellew |
Couple questions I have to be able to complete this:
|
more info here
|
|
@vito-c how's it going? i am planning to release 2.7.0 soon, please share your progress if you'd like it to be included. |
@kitbellew what's your eta? I am not quite there yet... The other thing I was thinking about is that people who didn't have braces before will get them added back in when they upgrade which might be problematic.
So how do I access the |
@vito-c all configuration settings are available via |
scalafmt.conf:
Input code:
output code:
That checks out and works as expected but it is impossible to undo the change by changing the maxLine
scalafmt.conf:
input code:
output code:
expected code:
The text was updated successfully, but these errors were encountered: