jhipster / prettier-java

Prettier Java Plugin
http://www.jhipster.tech/prettier-java/
Apache License 2.0
1.06k stars 103 forks source link

BUG: all spaces removed in text block line with only spaces #582

Closed TysonMN closed 1 year ago

TysonMN commented 1 year ago

Prettier-Java 2.1.0

Here is the contents of our .prettierrc.json file.

{
    "arrowParens": "avoid",
    "bracketSameLine": true,
    "bracketSpacing": false,
    "proseWrap": "always",
    "printWidth": 120,
    "trailingComma": "all"
}

Input:

The following text block has three lines and each line has three characters. All three characters in the middle line are spaces.

String myTextBlock = """
    foo

    bar
    """;

Output:

The following text block has three lines. The first and last liens both have three characters. The middle lines has no characters.

String myTextBlock = """
    foo

    bar
    """;

Expected behavior:

I expected the output to be the same as the input. In particular, prettier should not change the value of any string literal.

TysonMN commented 1 year ago

Ah, sorry. We realized that IntelliJ is to blame for this: https://youtrack.jetbrains.com/issue/IDEA-246734/trim-trailing-whitespace-should-not-apply-inside-multiline-strings