Skip to content

fix: omit indentation from text block assignments#980

Merged
jtkiesel merged 1 commit into
jhipster:mainfrom
jtkiesel:fix/text-block-indentation
Jul 14, 2026
Merged

fix: omit indentation from text block assignments#980
jtkiesel merged 1 commit into
jhipster:mainfrom
jtkiesel:fix/text-block-indentation

Conversation

@jtkiesel

Copy link
Copy Markdown
Contributor

What changed with this PR:

Text blocks are no longer indented when used as the value of an assignment expression. Prettier JS/TS doesn't have an equivalent to Java text blocks, where we can choose a level of indentation but cannot change the difference in indentation between the closing """ and the least-indented line. I've decided to align their formatting with that of method invocations or other parenthesized expressions, except that the contents can't have their indentation changed WRT the closing """ (or else the multiline string will be altered). I'm not absolutely sold on this way of formatting them, but I think it's a bit better than what is currently in main.

Example

Input

String source = """
  public void print(%s object) {
      System.out.println(Objects.toString(object));
  }
  """.formatted(
  aaaaaaaaaa,
  bbbbbbbbbb,
  cccccccccc,
  dddddddddd,
  eeeeeeeeee,
  ffffffffff
);

Output

String source = """
public void print(%s object) {
    System.out.println(Objects.toString(object));
}
""".formatted(
  aaaaaaaaaa,
  bbbbbbbbbb,
  cccccccccc,
  dddddddddd,
  eeeeeeeeee,
  ffffffffff
);

Relative issues or prs:

Closes #977

@jtkiesel jtkiesel merged commit 7560301 into jhipster:main Jul 14, 2026
6 checks passed
@jtkiesel jtkiesel deleted the fix/text-block-indentation branch July 14, 2026 05:33
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 this pull request may close these issues.

[2.10.2] Text block method call arguments not indented correctly in context of assignment

1 participant