Skip to content

Wrong indentation when there is a comment in a switch expression #768

@boris-petrov

Description

@boris-petrov

Prettier-Java 2.7.3

Playground link

--print-width 100

Input:

public abstract class Foo implements MyInterface {

	@Override
	public String foo() {
		switch (m) {
			case A a ->
				// comment
				result;
		}
	}
}

Output:

public abstract class Foo implements MyInterface {

	@Override
	public String foo() {
		switch (m) {
			case A a -> // comment
			result;
		}
	}
}

Expected behavior:

  1. the comment was moved which is unexpected;
  2. the result; line should be indented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions