Skip to content

Nested ternary indentation changes #5476

@vincentwoo

Description

@vincentwoo

Prettier 1.15.2
Playground link

--parser babylon

Input:

change.to.line < pos.line
  ? pos.ch
  : change.text.length <= 1
    ? pos.ch - (change.to.ch - change.from.ch) + sumLengths(change.text)
    : pos.ch - change.to.ch + last(change.text).length

Output:

change.to.line < pos.line
  ? pos.ch
  : change.text.length <= 1
  ? pos.ch - (change.to.ch - change.from.ch) + sumLengths(change.text)
  : pos.ch - change.to.ch + last(change.text).length;

Expected behavior:
Hi, I'm not sure when this prettier change was made, but it used to be the case that such ternary expressions were indented like the input text. Recently it seems that we get the shown output instead. I think the former is certainly superior for communicating intent. Was this an intended indentation (hah) change?

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.type:questionQuestions and support requests. Please use Stack Overflow for them, not the issue tracker.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions