Skip to content

Formatter should understand single line if-blocks without curlies #23334

Closed
@DartBot

Description

@DartBot

This issue was originally filed by [email protected]


Run the formatter with an 80 col limit on a single line if-block whose condition fits within 80 cols, but predicate does not. For example:
if (foo = "1234567890123456789012345678901234567890") bar = "12345678901234567890";

Notice it formats to:
if (foo = "1234567890123456789012345678901234567890") bar =
    "12345678901234567890";

I'd expect it to produce:
if (foo = "1234567890123456789012345678901234567890")
  bar = "12345678901234567890";

Or better yet, add the curlies as specified by https://www.dartlang.org/articles/style-guide/#do-use-curly-braces-for-all-flow-control-structures , thus producing:
if (foo = "1234567890123456789012345678901234567890") {
  bar = "12345678901234567890";
}

Note that the formatter does the right thing if the curlies are already present.

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