google / google-java-format

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

bug report: 1.21.0 IntelliJ vs jar inconsistency #1088

Closed ssh352 closed 3 months ago

ssh352 commented 3 months ago
Screenshot 2024-03-27 at 10 46 38

the top one is from

 java -jar /usr/local/bin/google-java-format-1.21.0-all-deps.jar --aosp --skip-sorting-imports -i A.java

the bottom one is from IntelliJ google java format plugin 1.21.0 version. It adds additional 4 spaces to the second line.

Please advise

cushon commented 3 months ago

Does passing --skip-reflowing-long-strings to the CLI match the IntelliJ behaviour?

Can you share the contents of A.java as text, instead of a screenshot?

ssh352 commented 3 months ago

--skip-reflowing-long-strings

the inconsistency comes from --skip-reflowing-long-strings. I want to use this option however.

class A {
    public static void main(String[] args) {
        System.out.println(
                "abc joijefoi owejf weifj oeijfwoiejf oweijf oweijf oweijf oweijf oweijf owej feoiwjfoweijf oweijf ");
    }
}
cushon commented 3 months ago

https://github.com/google/google-java-format/issues/566