google / google/google-java-format

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

Open
#1,114 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
6.2k
Forks
937
Avg merge
6m
Merged PRs (30d)
3

Description

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");
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.