redhat-developer / redhat-developer/vscode-java
CodeAction that modifies code in an unopened file doesn't work with two spaces indentation
未关闭
还没有人认领这个 Issue。
bug
formatter
- 主要语言
- TypeScript
- 星标
- 2.3k
- 派生
- 546
- 平均合并
- 20 小时 1 分钟
- 30 天内合并 PR
- 11
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
该 issue 未指定任何实现文件或测试。首先,在一个使用两个空格缩进且未设置显式缩进选项的已关闭 Java 文件上复现 CodeAction;当新插入的字段或方法使用该文件的两个空格缩进,并与预期结果一致时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100