Fix line breaks

I'd like to implement a fix myself, but I need some help
The behavior I expect is

let view = UIView { $0
  .backgroundColor(.red)
  .layer.cornerRadius(12)
}

view.onTap(caputre { _self in
  _self.backgroundColor = .random()
})

The behavior I get with swift-format is

let view = UIView {
  $0
    .backgroundColor(.red)
    .layer.cornerRadius(12)
}

view.onTap(
  caputre { _self in
    _self.backgroundColor = .random()
  }
)

I fixed it partially here, but now I'm getting

// lengths[idx] for some token is 400+ so PrettyPrinter adds a newline before the value of assignment expression
let view = 
  UIView { $0
  .backgroundColor(.red)
  .layer.cornerRadius(12)
}

// For just a call without assignment i get what i need
// self.configure { $0
//   .backgroundColor(.red)
//   .layer.cornerRadius(12)
// }

view.onTap(caputre { _self in
  _self.backgroundColor = .random()
})

see FunctionCallTests.testUnnamedArgumentFunctionCall

Terms of Service

Privacy Policy

Cookie Policy