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

Before commit reformatting option in IntelliJ does invoke plugin #228

Closed
mqzry opened this issue Nov 27, 2017 · 20 comments
Closed

Before commit reformatting option in IntelliJ does invoke plugin #228

mqzry opened this issue Nov 27, 2017 · 20 comments
Assignees
Labels

Comments

@mqzry
Copy link

mqzry commented Nov 27, 2017

I have the IntelliJ plugin installed and reformatting works as expected. If I select 'Reformat code' option in commit window, then it will take my currently selected Code Style sheet and not use google-java-format. It sets indentation to 4 spaces instead of 2 for example. Reformatting after committing then immediately gives local changes.

Is this a known issue? Will this be solved?

@mqzry
Copy link
Author

mqzry commented Jan 17, 2018

What's the status? Should I try to fix it myself?

@plumpy
Copy link
Collaborator

plumpy commented Jun 4, 2018

Hey there,

I tried to reproduce this, but was not able to. It's very old, though, so maybe it got fixed in some interim version.

Can you still reproduce it? What version of the plugin do you have and what version of the IDE?

Thanks and sorry for the delay...

@codahale
Copy link

codahale commented Jun 4, 2018

This is still a problem with 1.6.0 of the plugin and the latest version of IntelliJ (2018.1.4/IU-181.5087.20).

To reproduce:

  1. Enter some malformatted code into a file.
  2. Commit the change with the Reformat code checkbox enabled.
  3. The code will not be changed.
  4. Run Reformat Code from the Code menu.
  5. The code will be changed.

@mqzry
Copy link
Author

mqzry commented Jun 16, 2018

I tried it out again and it seems to be fixed.

My setup is:
IntelliJ @ IU-173.4548.28
google-java-format plugin @ 1.6.0

You are describing a different problem @codahale. Apparently 'Reformat code' in the commit dialog is doing nothing for you. My problem was that 'Reformat code' in the commit dialog was actually changing the files but without using the google-java-format plugin, hence falling back to my Code Style Sheet.

That should probably be filed as a separate issue, but that is not my call to make. This issue can be closed for my part.

@codahale
Copy link

Well, now I can’t reproduce my problem either, so I assume this is fixed.

@codahale
Copy link

Actually, no — I can confirm w/ 2018.1.5/IU-181.5281.24 that it uses the Code Style settings and not google-java-format. This was always the problem I was experiencing, but perhaps I didn’t describe it well.

@codahale
Copy link

To reproduce:

  1. Change a project’s Java code style to the IntelliJ default.
  2. Join a series of statements in a class on a single line.
  3. Commit the code, making sure the Reformat code checkbox is checked.
  4. Observe that the changed code was refomatted using the default IntelliJ style

@rymach
Copy link

rymach commented Jul 30, 2018

I'm also seeing this issue (version 1.6.1 of the plugin)

@alexbde
Copy link

alexbde commented Aug 6, 2018

We're also experiencing this issue. Is there any progress on this?

Reproducable on Windows 7 and macOS 10.13 with IntelliJ IDEA 2017.3, 2018.1 and 2018.2 using plugin 1.5.0 and 1.6.1.

gino-m added a commit to google/ground-android that referenced this issue Sep 5, 2018
@YanzheL
Copy link

YanzheL commented Mar 31, 2019

Same issue with IntelliJ 2019.1 (IU-191.6183.87), google-java-format v1.7.0.1
Environment:

  1. macOS 10.14.3, openjdk-8 and openjdk-11
  2. Ubuntu 18.04 LTS, openjdk-8 and openjdk-11

@YanzheL
Copy link

YanzheL commented Mar 31, 2019

It has been two years since this issue was posted, any progress?

@mleonhard
Copy link

I really wish I could use the automatic formatter.

IntelliJ IDEA 2019.1.1 (Community Edition)
Build #IC-191.6707.61, built on April 16, 2019
JRE: 1.8.0_202-release-1483-b44 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.4
google-java-format v1.7.0.1

@plumpy Please fix? This issue and #264 are assigned to you and have been ignored for 2 years.

@YanzheL
Copy link

YanzheL commented May 1, 2019

My current workaround is to use XML based intellij-java-google-style file instead of this google-java-format plugin.

It works fine, but the formatted code is slightly different from the output of this plugin.

@alexbde
Copy link

alexbde commented Jun 5, 2019

@YanzheL We're doing the same as workaround. We used plugin google-java-format for a while but not being able to use before commit action is confusing and frustrating our developers. This is a show stopper for us.

Last tested on
IntelliJ IDEA 2019.1.3 (Ultimate Edition)
Build #IU-191.7479.19, built on May 28, 2019
JRE: 1.8.0_202-release-1483-b58 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

@krasa
Copy link

krasa commented Oct 16, 2019

This should be just a matter of overriding public void reformatTextWithContext(PsiFile psiFile, ChangedRangesInfo changedRangesInfo)

@denniseffing
Copy link

Are there any plans to support this in the future?

@stonelazy
Copy link

Am having this exact same issue, any work arounds possible ? We face many merge conflicts due to this.

@Tommy544
Copy link

I am having the same issue, any update on this?

@Agraphie
Copy link

Also observing the same issue. The workaround with the codestyle.xml is nice, but the formatting can be wildly different. Especially regarding annotations (on single line, annotation indentation, ...) so the workaround is in the end not really sufficient as you still have to always apply the style either manually or via a maven plugin.

armbruer added a commit to armbruer/cpg that referenced this issue Nov 5, 2023
armbruer added a commit to armbruer/cpg that referenced this issue Nov 5, 2023
@vshamrai
Copy link

We faced the same issue. Can we expect that it will be fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.