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

Incorrect comment indentation inside switch statements on case that is not first #1155

Open
romani opened this issue Sep 1, 2024 · 1 comment

Comments

@romani
Copy link

romani commented Sep 1, 2024

continuation of #1147

$ javac Test.java 
$ cat Test.java 
public class Test {
  public void check1(int x) {
    switch (x) {
      case 1:
        x = x + 1;
      /* fall-through*/ case 2:
        ;
      default:
        return;
    }
  }
}

$ java -jar google-java-format-1.23.0-all-deps.jar Test.java > TestUpdated.java
$ diff -u Test.java TestUpdated.java 
--- Test.java	2024-09-01 07:31:37.268757862 -0700
+++ TestUpdated.java	2024-09-01 07:31:54.329333795 -0700
@@ -3,7 +3,7 @@
     switch (x) {
       case 1:
         x = x + 1;
-      /* fall-through*/ case 2:
+        /* fall-through*/ case 2:
         ;
       default:
         return;

$ cat TestUpdated.java 
public class Test {
  public void check1(int x) {
    switch (x) {
      case 1:
        x = x + 1;
        /* fall-through*/ case 2:
        ;
      default:
        return;
    }
  }
}
@cushon
Copy link
Collaborator

cushon commented Sep 10, 2024

I agree that ident is a bug, although I'd also encourage code following Google Style to use the 'typical' fall through comment the style guide suggests which is the line comment // fall through.

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