redhat-developer / redhat-developer/vscode-java
CodeAction that modifies code in an unopened file doesn't work with two spaces indentation
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
When I apply a CodeAction that modifies code in a file that isn't currently opened in VS Code, such as "create missing field asdf in Foo", and the file being modified is formatted to use two spaces as indentation, then the newly added content is not formatted correctly.
In order for this to happen, I don't specify any indentation settings in settings.json, and I don't add a .settings/org.eclipse.jdt.core.prefs.
Environment
- Operating System: RHEL 8
- JDK version:
- Visual Studio Code version: 1.69.2, 3b889b090b5ad5793f524b5d1d39fda662b96a2a, x64
- Java extension version: v1.10.2022080304
Steps To Reproduce
- Make a class FooA:
public class FooA {
private String prefix;
public FooA(String prefix) {
this.prefix = prefix;
}
public String getPrefix() {
return this.prefix;
}
}
- Close
FooA - Make a class FooB:
public class FooB {
private FooA fooA;
public FooB(FooA fooA) {
this.fooA = fooA;
}
public String getParameter() {
return this.fooA.parameter;
}
}
- Activate the "Create field 'parameter' in type 'FooA'" CodeAction
Current Result
FooA becomes:
public class FooA {
private String prefix;
public String parameter;
public FooA(String prefix) {
this.prefix = prefix;
}
public String getPrefix() {
return this.prefix;
}
}
Expected Result
FooA becomes:
public class FooA {
private String prefix;
public String parameter;
public FooA(String prefix) {
this.prefix = prefix;
}
public String getPrefix() {
return this.prefix;
}
}
Additional Informations
- You can reproduce this bug using other CodeActions, like the "Create method" one
- If indentation settings are set in a
settings.jsonor.settings/org.eclipse.jdt.core.prefs, the newly added content respects those settings as expected
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
Das Issue nennt keine Implementierungsdateien oder Tests. Reproduziere zuerst die CodeAction in einer geschlossenen Java-Datei mit einer Einrückung von zwei Leerzeichen und ohne explizite Einrückungseinstellungen; die Aufgabe ist erfüllt, wenn neu eingefügte Felder oder Methoden die Einrückung von zwei Leerzeichen der Datei verwenden und dem erwarteten Ergebnis entsprechen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100