Skip to content

Conversation

@jtkiesel
Copy link
Contributor

What changed with this PR:

Non-block switch rule bodies with leading comments are now indented properly.

Example

Input

class Example {

  void example() {
    switch (a) {
      case b ->
        // comment
        c;
      case Dd d ->
        // comment
        e;
      case f ->
        // comment
        throw new RuntimeException();
    }
  }
}

Output

class Example {

  void switchRulesWithComments() {
    switch (a) {
      case b ->
        // comment
        c;
      case Dd d ->
        // comment
        e;
      case f ->
        // comment
        throw new RuntimeException();
    }
  }
}

Relative issues or prs:

Closes #768

@jtkiesel jtkiesel merged commit 9ef6af0 into main Sep 21, 2025
10 checks passed
@jtkiesel jtkiesel deleted the fix/switch-rule-body-leading-comment branch September 21, 2025 01: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.

Wrong indentation when there is a comment in a switch expression

2 participants