google / google-java-format

Reformats Java source code to comply with Google Java Style.
Other
5.49k stars 848 forks source link

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

Open jdcormie opened 3 weeks ago

jdcormie commented 3 weeks ago

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