intellij-ideacode-standards

Format code to align with its own subsection clause


Currently using IntelliJ 2018.2.3.

What option(s) in the Code Style (or anywhere else) should be checked/unchecked to achieve the following behavior?

Intended behavior:

@Override
public boolean equals(Object other) {
    return other == this // short circuit if same object
            || (other instanceof UniquePersonList // instanceof handles nulls
               && this.internalList.equals(((UniquePersonList) other).internalList)); <--
}

Current behavior

@Override
public boolean equals(Object other) {
    return other == this // short circuit if same object
            || (other instanceof UniquePersonList // instanceof handles nulls
            && this.internalList.equals(((UniquePersonList) other).internalList)); <--
}

Currently, everytime when I auto format the code, it shifts the && to be align with ||. But it is clear that the && belongs to the subsection of the 2nd clause.


Solution

  • Try Code Style | Java | Wrapping and Braces | Binary expressions | Align when multiline.