Skip to content

Empty array initializer with line-end comment folded wrongly #782

@csemrau

Description

@csemrau

Tested to fail with prettier-plugin-java 2.7.5 and 2.7.0, and work with 2.6.8, using prettier 3.5.3.

Have this as a field or variable declaration.

    String[] DATA = {
        // nothing yet 
    };

It gets formatted like this, which does not compile.

    String[] DATA = { // nothing yet };

2.6.8 does not change the code at all.
I'd be fine with keeping the comment on its own line, or with moving it to the end of the collapsed line like so:

    String[] DATA = {}; // nothing yet

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions