Skip to content

Formatter: Comment moved in nested conditions #2372

@spotandjake

Description

@spotandjake
if(
  true
    && (
      true
      && "really long string that causes line break in the structure" == ""
    ) // Comment moved
) {
  void
}

It seems the above code gets formatted a little weirdly when we have a nested condition with a breaking group inside it, it seems that we end up moving the comment down two lines which is rather bizar, interestingly this doesn't seem to apply to when we wrap in a function rather than a condition.

if (
  true
  && (
    true
    && "really long string that causes line break in the structure" == ""
  )

  // Comment moved
) {
  void
}

Is the resulting format

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggrainfmtIssues related to the Grain formatter

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions