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 not stable with comment in if statement #592

Open
jmattheis opened this issue Jul 31, 2023 · 0 comments · May be fixed by #595
Open

Formatting not stable with comment in if statement #592

jmattheis opened this issue Jul 31, 2023 · 0 comments · May be fixed by #595

Comments

@jmattheis
Copy link

Prettier-Java 2.2.0

The formatting is not stable with the following code structure and needs to be run twice to get to a stable state:

$ yarn add prettier prettier-plugin-java
$ cat initial.java
package main;

class Main {

  public static void main(String[] args) {
    if (true) // comment
    {
      System.out.println("Oops");
    }
  }
}
$ yarn -s prettier --plugin prettier-plugin-java initial.java | tee first.java
package main;

class Main {

  public static void main(String[] args) {
    if (
      true
    ) { // comment
      System.out.println("Oops");
    }
  }
}
$ yarn -s prettier --plugin prettier-plugin-java first.java | tee second.java
package main;

class Main {

  public static void main(String[] args) {
    if (true) { // comment
      System.out.println("Oops");
    }
  }
}

Expected behavior:

The prettier-java-plugin should only require one format execution to properly format the code.

jtkiesel added a commit to jtkiesel/prettier-java that referenced this issue Aug 6, 2023
jtkiesel added a commit to jtkiesel/prettier-java that referenced this issue Aug 6, 2023
jtkiesel added a commit to jtkiesel/prettier-java that referenced this issue Aug 15, 2023
jtkiesel added a commit to jtkiesel/prettier-java that referenced this issue Aug 15, 2023
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

Successfully merging a pull request may close this issue.

1 participant