[Feature request] Split into multiple lines if a line including comments exceed the maximum width
I propose we ... add a feature that formats a statement into a line including comments that don't exceed the maximum width.
The existing way of Fantomas deals with this problem is ... When I format the code, the line of code including the comments sometimes exceeds the maximum width, but the line of code without comments doesn't exceed the maximum width.
Pros and Cons
The advantages of making this adjustment to Fantomas are ... Easier to read
The disadvantages of making this adjustment to Fantomas are ... None
Examples
Please provide multiple examples (before and after scenarios) and explain what rules did apply to achieve the outcome. Input:
let complex_function first second third fourth last = first + second + third + fourth + last // complex function
Actual Output:
let complex_function first second third fourth last = first + second + third + fourth + last // complex function
Expected Output:
let complex_function first second third fourth last =
first + second + third + fourth + last // complex function
Input:
let very_complex_function first second third fourth fifth last = first + second + third + fourth + fifth + last // very complex function
Actual Output:
let very_complex_function first second third fourth fifth last =
first + second + third + fourth + fifth + last // very complex function
Expected Output:
let very_complex_function first second third fourth fifth last =
first + second + third + fourth + fifth + last // very complex function
Affidavit (please submit!)
Please tick this by placing a cross in the box:
- [x] I have read the Contribution Guidelines.
- [x] I have searched both open and closed suggestions on this site and believe this is not a duplicate
Please tick all that apply:
- [x] 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)
Hello, thank you for your interest. At first glance, I don't think this is deemed problematic by the current userbase. (As it was never brought up until now)
Could you provide some more examples where you are bumping into this use-case? Please use the online tool where possible.
let complex_function first second third fourth last = first + second + third + fourth + last // this is a complex function
let complex_function first second third fourth last = first + second + third + fourth + last this is a complex Function
These examples are repetitive, and they don't broaden the scope of your expectations. The technical details surrounding this situation are quite unclear, particularly regarding the predefined rules and what changes would be necessary to achieve it. How significant would the impact be?
The above code is formatted based on the line length of the code excluding comments, instead of the line length of the code including comments. So the above code is formatted and the line length of code excluding comments always doesn't exceed the maximum line width, sometimes the line length of code can exceed the maximum line width.