google / google/google-java-format

Formatting overly long lines does not respect `--lines` range restriction

未關閉
#1,114 1 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Java
星號
6.2k
分支
937
平均合併
6 分鐘
30 天內合併 PR
3

描述

Let Test.java be:
```
class Test {
void foo() {
// Columns:
// 1 2 3 4 5 6 7 8 9
// ..0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
System.err.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
}
}
```

What I did: `$ google-java-format --lines 1:1 Test.java | diff Test.java -`
What I expected to happen: No diff, since line 1 is already correctly formatted.
What actually happens:
```
6c6,7
< System.err.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
---
> System.err.println(
> "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
```

貢獻指南

開啟貢獻指南

研究方向

Reproduce the issue with the provided Test.java example and `google-java-format --lines 1:1 Test.java`, then trace how the `--lines` range is applied to overly long lines. Done means the command produces no diff when the selected line is already correctly formatted, while formatting remains unchanged outside the requested range.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java
領域
tooling
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。