Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jdcormie opened this issue Jun 18, 2024 · 1 comment
Open

Comments

@jdcormie
Copy link

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");
jdcormie added a commit to grpc/grpc-java that referenced this issue Jun 24, 2024
https://github.com/grpc/grpc-java/blob/master/CONTRIBUTING.md#code-style

We've been talking about an incremental approach in #1664 but google/google-java-format#1114 causes a bunch of manual formatting toil every time I run ~/google-java-format-diff.py because we have a LOT of lines >100 characters. Establishing a gjf-clean baseline will make things a lot easier for me.
@sugamadhiakri
Copy link

sugamadhiakri commented Jul 29, 2024

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?

larry-safran pushed a commit to larry-safran/grpc-java that referenced this issue Aug 13, 2024
https://github.com/grpc/grpc-java/blob/master/CONTRIBUTING.md#code-style

We've been talking about an incremental approach in grpc#1664 but google/google-java-format#1114 causes a bunch of manual formatting toil every time I run ~/google-java-format-diff.py because we have a LOT of lines >100 characters. Establishing a gjf-clean baseline will make things a lot easier for me.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants