Skip to content

Brackets are formatted in a weird way when followed by chained calls #631

Description

@Yqloss

Current behavior:

fun main() {
  {
      println("-----------------------------------")
      println("-----------------------------------")
    }
    .invoke()

  [
      println("-----------------------------------"),
      println("-----------------------------------"),
    ]
    .map { it }

  val a =
    [
        println("-----------------------------------"),
        println("-----------------------------------"),
      ]
      .map { it }
}

They just feel weird, and this problem would get worse and worse with the stabilization of collection literals because the pattern of constructing a list and do operations on it is so common. The current formatting is too weird to be acceptable.

Why don't we put ] ) } at the same indentation of the line containing [ ( {, and move the dot to align with ] ) } as well, so that everything would look nice?

fun main() {
  {
    println("-----------------------------------")
    println("-----------------------------------")
  }
  .invoke()

  [
    println("-----------------------------------"),
    println("-----------------------------------"),
  ]
  
  [
    println("-----------------------------------"),
    println("-----------------------------------"),
  ]
  .map { it }

  val a =
    [
      println("-----------------------------------"),
      println("-----------------------------------"),
    ]
    .map { it }

  run(
    block = {
      println("-----------------------------------")
      println("-----------------------------------")
    }
  )
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions