Open Allc9001 opened 3 years ago
Possibly related to #642
The CLI has a separate pass that reflows long strings literals (corresponding to --skip-reflowing-long-strings
):
The IntelliJ plugin currently just runs the core formatter logic, not the string reflowing part.
Hi, we want to start using the plugin in IntelliJ and Eclipse IDE and format code on Save Actions and also in GitHub workflows using the axel-op/googlejavaformat-action. But, it gives different results and our GitHub workflow fails due to unformatted code, even if all code is formatted in the IDE. Is there any workaround for this in IntelliJ and Eclipse plugin or maybe a fix coming?
@eShorko don't hold your breath. I've added git hooks to format all code with the cli on commit to keep things consistent and force the same formatting for everything that is committed.
This is causing me grief at work as well.
too bad IntelliJ plugin still cannot line break cc https://github.com/google/google-java-format/issues/800
So... this has been a problem for me too and after I debugged the source of the problem I found my way here.
Is there any reason why the IntelliJ plugin doesn't reflow long strings by default, @cushon ? Seems like an easy fix to add:
formatted = StringWrapper.wrap(formatted, this);
to the plugin. One could even make it configurable, much like the formatting style. I can produce a patch but wanted to make sure it's not some kind of policy to not make any structural changes to the code in the plugin (I don't see the reason for it).
If I format the following file using the intellij plugin (IDE version: Ultimate
2020.2.4
/ plugin version: google-java-format1.9.0.0
. ) I get different result when compared to using the jar on the command line.original example file:
after formatting using intellij plugin (using menu code / reformat code) I get this:
And after formatting on the command line:
I get this: