Skip to content

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

Closed

Description

@jdcormie

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

Activity

  1. sugamadhiakri commented on Jul 29, 2024

    @sugamadhiakri

    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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions