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

Splitting previously split lines on logical separators if available #924

Closed
Nixxen opened this issue Jul 5, 2023 · 1 comment · Fixed by #934
Closed

Splitting previously split lines on logical separators if available #924

Nixxen opened this issue Jul 5, 2023 · 1 comment · Fixed by #934

Comments

@Nixxen
Copy link
Contributor

Nixxen commented Jul 5, 2023

Splitting lines not solely on the width but also on width + logical separators makes the code more readable (subjectively).

Example

Example code with logical checks, just exceeding a 100-character config limit.

Original Line, 103 char long. Over the 100-char config limit.

            else if (VariableNameOneAaaaaaaa > VariableNameTwoBbbbbb && VariableNameOneAaaaaaaa > 0.0)

When formatted ends up like the following, 97 char long at the widest, under the 100-char config limit.

            else if (
                VariableNameOneAaaaaaaa > VariableNameTwoBbbbbb && VariableNameOneAaaaaaaa > 0.0
            )

In my opinion, this would look better by either keeping it at 103 and not breaking or, preferably, breaking it further like so:

            else if (
                VariableNameOneAaaaaaaa > VariableNameTwoBbbbbb 
                && VariableNameOneAaaaaaaa > 0.0
            )

Currently, the last example will be formatted back to the middle example.

@belav
Copy link
Owner

belav commented Aug 11, 2023

From my testing, it seems like a difference of just two characters can result in the 3 formats below, regardless of the indentation level. I am on board with trying to eliminate the second option. I may actually have an issue about this already.

if (somelongstatement == true || someOtherStatement_______________________________________ == false)
{
    // do thing
}
if (
    somelongstatement == true || someOtherStatement________________________________________ == false
)
{
    // do thing
}
if (
    somelongstatement == true
    || someOtherStatement_________________________________________ == false
)
{
    // do thing
}

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

Successfully merging a pull request may close this issue.

2 participants