Skip to content

Opening delimiter of text block should not be on a new line #1227

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

Closed
anthonyvdotbe opened this issue Mar 22, 2025 · 1 comment
Closed

Opening delimiter of text block should not be on a new line #1227

anthonyvdotbe opened this issue Mar 22, 2025 · 1 comment

Comments

@anthonyvdotbe
Copy link
Contributor

The opening delimiter of a text block cannot be followed by anything useful, so it will always be on a line of its own.
I assume this is a consequence of the rectangle rule, and I understand this rule is kind of the core principle of g-j-f, but in cases like this (and #19) I would much prefer g-j-f to give priority to readability and intuitive formatting.

For the record, see also G4 in the Programmer’s Guide to Text Blocks.

input:

class Test {

    String a =
            """
      foo
      """;
}

expected:

class Test {

    String a = """
      foo
      """;
}

actual:

class Test {

    String a =
            """
      foo
      """;
}
@cushon
Copy link
Collaborator

cushon commented Mar 27, 2025

I assume this is a consequence of the rectangle rule, and I understand this rule is kind of the core principle of g-j-f

I think that's a lot of it. There was a bunch of discussion with the owners of the Google Java Style Guide before deciding on the current formatting. I understand the preference for keeping """ on the previous line, and I agree there's some overlap with #19, but the current behaviour is what we've settled on for now.

Also this is perhaps just a typo, but the output should be something like the following, with both delimiters aligned:

class Test {

  String a =
      """
      foo
      """;
}

@cushon cushon closed this as completed Mar 27, 2025
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

No branches or pull requests

2 participants