-
-
Notifications
You must be signed in to change notification settings - Fork 204
Option to reduce multiple blank lines from source code #2243
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
Option to reduce multiple blank lines from source code #2243
Conversation
nojaf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! I've added one remark in terms of creating the Newline trivia, that might be an interesting one to consider. Otherwise, a couple of nits but nothing serious.
I would also like to see the edge cases here. I wasn't able to see the limitations that fsharp_keep_max_blank_lines=0 has.
We could have this as an ignored test to highlight we are at least aware of when this will do weird things.
Well done!
It can be seen from my experiment here #2198 (comment) (it was POC, but result should be same - I try to reproduce same thing with this implementation later). I will create ignored test highlighting problematic case from this. |
I'm not entirely sure about that, because this time, less trivia was assigned to a trivia node and I believe in the original POC the newlines were swallowed in CodePrinter. |
|
I made requested changes. Fantomas.Core formatted with fsharp_keep_max_number_of_blank_lines=0 is here: jindraivanek@ece950f Only thing missing is ignored test(s) with problematic cases from there. |
nojaf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spot on! Thank you.
Fix #2198.
Introduce new config option
KeepMaxBlankLinesthat set maximal number of consecutive blank lines from source code that is kept in formatted code.I'm open to suggestion to better name for new option.
Option is now implemented as a number, with big value as default. Is it OK, or it should be
Num option?KeepMaxBlankLines=0reveals multiple cases where Fantomas should add blank lines - I think this should be solved as separate issue(s).Checklist:
NumorNum option?KeepMaxBlankLines=0