Skip to content

Conversation

@jtkiesel
Copy link
Contributor

@jtkiesel jtkiesel commented Oct 1, 2025

What changed with this PR:

Ternary expression comment placement and indentation are now aligned with those used by Prettier for JavaScript.

Example

Input

class Example {

    void example() {
        a
            ? // b
            b
            : // c
            c;
        a
            // b
            ? b
            // c
            : c;
        a ? // b
            b
            : // c
            c;
        a
            ? b // b
            : c; // c
    }
}

Output

class Example {

    void example() {
        a
            ? // b
              b
            : // c
              c;
        a
            ? // b
              b
            : // c
              c;
        a // b
            ? b
            : // c
              c;
        a
            ? b // b
            : c; // c
    }
}

Relative issues or prs:

Closes #758
Closes #779

@jtkiesel jtkiesel merged commit 9e931a9 into main Oct 1, 2025
10 checks passed
@jtkiesel jtkiesel deleted the fix/ternary-comments-and-indentation branch October 1, 2025 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong comment placement in ternary Not indempotent at ternary operator with comment

2 participants