IntelliJ not performing left-right evalution for formatting long line
I have this long line that has nested method definitions:
const possibleValues: Set<number>[][] = board.map((cols, row) => cols.map((value, col) => value === 0 ? new Set<number>(ALL_VALUES) : new Set<number>().add(board[row][col])));
I have a limit of 100 characters per line. IntelliJ (WebStorm, specifically) is choosing to format it this way:
const possibleValues: Set<number>[][] = board.map((cols, row) => cols.map((value, col) => value
=== 0
? new Set<number>(
ALL_VALUES)
: new Set<number>().add(
board[row][col])));
That is not a typo on my part. The `ALL_VALUES` and `board[row][col])));` are actually set that far in.
I would prefer it to be formatted this way:
const possibleValues: Set<number>[][] =
board.map(
(cols, row) =>
cols.map(
(value, col) =>
value === 0
? new Set<number>(ALL_VALUES)
: new Set<number>().add(board[row][col])));
I'm happy to share my settings, and maybe someone has experienced something similar and can give me guidance. But, I think the root of the problem is simply that IntelliJ is performing some sort of right-to-left evaluation of the line rather than left-to-right evaluation. Or, it's prioritizing things in a non-obvious way. Is there any way I can customize the evaluation order, e.g. always chop down right after an assignment first?
Please sign in to leave a comment.
please share your code style preferences (
<IDEA config dir>/codestyles/<scheme name>.xmlif you are using IDE-level scheme, or.idea\codeStyles\Project.xmlwhen using a project scheme)Thanks!
Disabling Align when multiline for ternary expressions in Settings | Editor | Code Style | TypeScript | Wrapping and Braces should make things better
Thanks!!! (Sorry for the late reply.)