palantir-java-format icon indicating copy to clipboard operation
palantir-java-format copied to clipboard

Palantir formatter behaves weirdly with switch assignments

Open kristofbolyai opened this issue 1 year ago • 1 comments

What happened?

How code was written:

        float renderX, renderY;

        renderX = switch (horizontalAlignment) {
            case Left -> x;
            case Center -> x - font.width(text) / 2f;
            case Right -> x - font.width(text);
        };

        renderY = switch (verticalAlignment) {
            case Top -> y;
            case Middle -> y - font.lineHeight / 2f;
            case Bottom -> y - font.lineHeight;
        };

After Palantir (2.26.0) format:

        float renderX, renderY;

        renderX = switch (horizontalAlignment) {
            case Left -> x;
            case Center -> x - font.width(text) / 2f;
            case Right -> x - font.width(text);};

        renderY = switch (verticalAlignment) {
            case Top -> y;
            case Middle -> y - font.lineHeight / 2f;
            case Bottom -> y - font.lineHeight;};

}; is in a weird place now.

What did you want to happen?

My suggestion is that }; should be auto-formatted to be in the next line after the last case.

kristofbolyai avatar Sep 18 '22 13:09 kristofbolyai

#782

lazystone avatar Feb 23 '23 17:02 lazystone