-
Notifications
You must be signed in to change notification settings - Fork 255
Description
We recently enabled running swift-format as a pre-commit hook, and while setting up the configuration/rules I noticed that there doesn't seem to be a way to enforce the standard alignment of let declarations on multiple lines.
E.g.: When typing the following in Xcode, each let aligns perfectly vertical with the first let after pressing Enter:
class TestClass {
var x: Bool? = true
var y: Bool? = false
var z: Bool? = true
func test() -> String {
if let x = self.x,
let y = self.y,
let z = self.z
{
return "Hello"
} else {
return "Goodbye"
}
}
}
But once I run swift-format, all the let:s with the exception of the first one is indented one whitespace further!
class TestClass {
var x: Bool? = true
var y: Bool? = false
var z: Bool? = true
func test() -> String {
if let x = self.x,
let y = self.y,
let z = self.z
{
return "Hello"
} else {
return "Goodbye"
}
}
}
This looks ugly, and it's weird that the linter would enforce a standard that doesn't match the editor behavior, especially without an option to turn it off. Is it perhaps a bug?
I'm using swift-driver version: 1.127.14.1 Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)
Target: arm64-apple-macosx26.0