Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double indentation of Ternary Operator with multiline method calling #1085

Closed
yelliver opened this issue Dec 24, 2021 · 2 comments
Closed

Double indentation of Ternary Operator with multiline method calling #1085

yelliver opened this issue Dec 24, 2021 · 2 comments

Comments

@yelliver
Copy link

yelliver commented Dec 24, 2021

We have this formatted code snippet:

void main() {
  var result = condition
      ? doA(                                     //6-space indentation here
          param1,
          param2,
        )
      : doB();
}

it should be like this:

void main() {
  var result = condition
    ? doA(                                       //should be 4-space indentation
        param1,       
        param2,
      )
    : doB();
}
@munificent
Copy link
Member

This is formatted as expected. Expression indentation is generally +4 and in the formatted code you can see the ? is indented four spaces relative to var, which is the statement that contains it.

@munificent
Copy link
Member

I tested this example out using the forthcoming tall style. Here's what it produces:

void main() {
  var result =
      condition
          ? doA(
            param1, // comment to force split
            param2,
          )
          : doB();
}

Splitting between = and condition isn't ideal and is because of #1465. Aside from that, the rest of the indentation is what I expect. As I mentioned in the previous comment, expressions are generally indented +4 relative to the surrounding code, which is what the ? and : lines relative to condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants