Skip to content

Line breaks not respected in statement conditions #1038

@AnthonyLatsis

Description

@AnthonyLatsis

Before:

switch x {
case let term
where
  term.hasPrefix("screen") ||
  term.hasPrefix("xterm") ||
  term.hasPrefix("vt100") ||
  term.hasPrefix("rxvt") ||
  term.hasSuffix("color"):
  return false
}

if term.hasPrefix("screen") ||
  term.hasPrefix("xterm") ||
  term.hasPrefix("vt100") ||
  term.hasPrefix("rxvt") ||
  term.hasSuffix("color")
{
  return false
}

After:

switch x {
case let term
where
  term.hasPrefix("screen") || term.hasPrefix("xterm") || term.hasPrefix("vt100") || term.hasPrefix("rxvt")
  || term.hasSuffix("color"):
  return false
}

if term.hasPrefix("screen") || term.hasPrefix("xterm") || term.hasPrefix("vt100") || term.hasPrefix("rxvt")
  || term.hasSuffix("color")
{
  return false
}

Interestingly, the formatter doesn’t mind

if term.hasPrefix("screen")
  || term.hasPrefix("xterm")
  || term.hasPrefix("vt100")
  || term.hasPrefix("rxvt")
  || term.hasSuffix("color")
{
  return false
}

I could not file a rule for specifying breaking behavior around operators, so presumably it should not matter to the formatter.

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