Skip to content

Wrong comment placement in ternary #779

@boris-petrov

Description

@boris-petrov

Prettier-Java 2.7.5

Playground link

--print-width 55

Input:

public abstract class Foo implements MyInterface {
  @Override public String foo() {
    return true
      ? // foo
      1
      : // bar
      2; 
  }
}

Output:

public abstract class Foo implements MyInterface {

	@Override
	public String foo() {
		return true // foo
			? 1 // bar
			: 2;
	}
}

Expected behavior:

Either the ternary to not be modified or something like:

public abstract class Foo implements MyInterface {

	@Override
	public String foo() {
		return true
			? 1 // foo
			: 2; // bar
	}
}

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