-
-
Notifications
You must be signed in to change notification settings - Fork 204
Description
I propose we add a new setting to reduce multiple blank lines to one single blank line.
The existing way of Fantomas deals with this problem is always restoring all the found blank lines.
Pros and Cons
The advantages of making this adjustment to Fantomas are that the number of blank lines is also more consistent. If the source text contains a multitude of blank lines, this will stay there after formatting. This is undesirable as Fantomas already has some heuristics in place for placing blank lines. To remain consistent, the user should not be in control of this.
The disadvantage of making this adjustment to Fantomas is introducing yet another setting. As this proposal changes the default behaviour, I'm sure that some users will prefer that all blank lines are preserved.
Examples
let a =
// ...
// ...
42
let b = 17would be formatted to
let a =
// ...
// ...
42
let b = 17Technical remarks
In the past, I recall an experiment where no blank lines were preserved as trivia. This didn't work out in all scenarios.
module X
// foo
let a = 0would have lead to
module X
// foo
let a = 0Due to the way colWithNlnWhenItemIsMultiline works.
It seems viable to reduce the number of blank lines assigned to a trivia node, but not to remove them completely.
This reduction should be done in Trivia module to ensure everything in CodePrinter works as expected.
Extra information
When the design is complete, this should be added to the next major branch (v5, get-back).
Estimated cost (XS, S, M, L, XL, XXL): S
Related suggestions: I'm pretty sure this has been requested in the past, but I could not find the issue anymore.
Affidavit (please submit!)
Please tick this by placing a cross in the box:
- I have read the Contribution Guidelines.
- I have searched both open and closed suggestions on this site and believe this is not a duplicate
Please tick all that apply:
- This is not a breaking change to Fantomas
- I or my company would be willing to help implement and/or test this
- This suggestion is part of the Microsoft style guide (please add a link to section if so)
- This suggestion is part of the G-Research style guide (please add a link to section if so)
//cc @jindraivanek @JonCanning