redhat-developer / redhat-developer/vscode-java
Inconsistency in line break "{}" formatting in Java with in VS Code
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 2.3k
- Forks
- 546
- Ø Merge
- 20 Std. 1 Min.
- Gemergte PRs (30 T.)
- 11
Beschreibung
In my VSC I have the extension called "Language support for java(TM) by red hat". The typical one that all of us who do Java have and this is self-evident. The formatter of said extension does not format correctly. Surely the formatting is taken from LLVM so there is some error or even some incorrect syntax when formatting
When I format in VSC this example code with java or java spring boot:
❌Incorrect - If I format like this, it leaves it like this
This happens on both the opening "{" and the ending "}". It seems that the extra space has no influence since the format accepts both together and extra spacing. When the correct one is the second one with the extra spacing.
| Incorrect | Preview |
|---|---|
| ❌ | ![]() |
| ✅ | Also say the formatting of the extension also leaves it like this if the code is like this.![]() |
3 incorrect formats accepted by the formatter have been shown. Therefore, if there is any code "in that format", the formatter will leave it that way. Only the correct one is the last one or the one made by Eclipse.
This doesn't make much sense since the code is stuck above or below or even between the curly braces "{}".
This way of formatting is not expected for those of us who work with Java. Eclipse does well in this regard.
✅ correct - This is how Eclipse does it. It doesn't matter how messy the code is. It will leave it like this:
| Correct | Preview |
|---|---|
| ✅ | ![]() |
I have tried countless things, none of them worked.
This has worked since 2007 in eclipse. We are in 2024. As an example of a good format:

How do you solve this problem and get the correct form, like correct or equal to eclipse?
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere das Verhalten bei der Formatierung von geschweiften Klammern und Zeilenumbrüchen in der Java VS Code extension anhand der Beispiele und Screenshots im Bericht und vergleiche anschließend die Ausgabe mit Eclipse. Verfolge das Formatter-Verhalten vom Einstiegspunkt für die Java-Formatierung der Extension aus und ermittle, ob die Abweichung durch die Konfiguration oder die Implementierung verursacht wird. Erledigt ist die Aufgabe, wenn die gemeldeten Layouts auf das erwartete Eclipse-style-Ergebnis normalisiert sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java, vscode
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100

