Skip to content
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

Comment after code is not correctly indented when wrapped to the next line #1152

Open
jamg76 opened this issue Oct 17, 2024 · 0 comments
Open

Comments

@jamg76
Copy link

jamg76 commented Oct 17, 2024

What happened?

This behaviour is observed when using spotless-plugin-gradle:6.25.0. It is also observed for the develop branch (as of 17 October 2024) in this repo, when trying it as input in a unit test (FormatterTest). It occurs for style 'palantir':

This input

class ClassB extends ClassA {
  @Test
  void shouldDoThisAndThat() {
    instance.shouldDoSomething(Set.of(
        "abcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijk", // prio (yet to go live)
        "abcdefghijkabcdefghijkabcdefghijkabjkghijkabcdefghij", // prio low, not exposed yet only for manual use
        "abcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkghijkabcdefghij" // prio low, not exposed yet only for manual use
        ));
  }
}

results in the following formatted output. The second and third line of the comment are not indented correctly:

class ClassB extends ClassA {
  @Test
  void shouldDoThisAndThat() {
    instance.shouldDoSomething(Set.of(
        "abcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijk", // prio
        // (yet to
        // go live)
        "abcdefghijkabcdefghijkabcdefghijkabjkghijkabcdefghij", // prio low, not exposed yet only
        // for manual use
        "abcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkghijkabcdefghij" // prio low, not exposed yet only for manual use
        ));
  }
}

What did you want to happen?

After the line wrap, the comment should start in the same column as the comment in the first line.

This is how the indentation should look like:

class ClassB extends ClassA {
  @Test
  void shouldDoThisAndThat() {
    instance.shouldDoSomething(Set.of(
        "abcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijk", // prio
                                                                                         // (yet to
                                                                                         // go live)
        "abcdefghijkabcdefghijkabcdefghijkabjkghijkabcdefghij" // prio low, not exposed yet only for
                                                               // manual use
        ));
        ...
  }
}

Interestingly, it works correctly if I remove the last long line:

"abcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkghijkabcdefghij" // prio low, not exposed yet only for manual use:
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

1 participant