Skip to content

[Feature request] Split into multiple lines if a line including comments exceed the maximum width #3136

Open
@lulunac27a

Description

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:

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions