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

[Formatter] no whitespace after block-less else with following non-alphanumeric tokens #3485

Open
Madjosz opened this issue Dec 20, 2024 · 0 comments

Comments

@Madjosz
Copy link

Madjosz commented Dec 20, 2024

The code formatter formats single line else without block and "New Lines -> In control statements -> 'if else' -> Keep 'else' statement on same line" without following white space if the next token does not need to be separated by a space.
Additional: "Compact 'if else' -> Force Split" is completely ignored with the above setting activated.

So for the follwing else statements the space will be removed:

else ++i;
else "".toString();
else (a).toString();
else """
       """.toString();

This also can lead to strange side effects like the save action "Use parenthesis in expressions -> Only if necessary" will transform else(someVar).toString(); to the invalid code elsesomeVar.toString(), although this might be a separate bug which needs to be checked when this is fixed.

Versions

Eclipse SDK
Version: 2024-12 (4.34)
Build id: I20241120-1800

openjdk version "21.0.4" 2024-07-16 LTS
OpenJDK Runtime Environment Temurin-21.0.4+7 (build 21.0.4+7-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.4+7 (build 21.0.4+7-LTS, mixed mode, sharing)

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

No branches or pull requests

1 participant