google/google-java-format

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

jdcormie opened this issue · 1 comments

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

Hi, @cushon I've been getting this issue while using google-java-format.py as it uses --lines to format the git-diff.

Can I try to work on the fix?