Skip to content

Multiline comment formatting not idempotent #279

@jhaber

Description

@jhaber

I'm seeing an issue with multiline comments getting extra indentation each time they get run through prettier-java

Input:

public class Example {
  
  public void method() {
    /*
      multiline comment
     */
  }
}

Output: (after running prettier ~5 times)

public class Example {

  public void method() {
    /*
                multiline comment
   */
  }
}

Each run of prettier seems to indent the comment a little more.

The issue doesn't manifest if each line of the comment is prefixed with an asterisk (although the formatting in this case still looks a little bit off), for example:

Input:

public class Example {

  public void method() {
    /*
     * multiline comment
     */
  }
}

Output:

public class Example {

  public void method() {
    /*
   * multiline comment
   */
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: bug 🐛Something isn't workingstatus: PR doneThe PR to fix this issue is donetheme: commentsIssue caused by comments handling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions