Skip to content
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

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

Open
3 of 6 tasks
lulunac27a opened this issue Nov 12, 2024 · 4 comments

Comments

@lulunac27a
Copy link

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)
@nojaf
Copy link
Contributor

nojaf commented Nov 13, 2024

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.

@nojaf
Copy link
Contributor

nojaf commented Nov 13, 2024

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?

@lulunac27a
Copy link
Author

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.

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

No branches or pull requests

2 participants