SwiftFormat is giving me extra indentation when formatting code inside an #if block and I don't know why.
I'd like to format the following code as shown:
Essentially, I want to disable a block of code using #if but keep what's inside the block formatted as usual.
public struct IfIndentView: View {
public var body: some View {
Text("Hello")
}
#if false
// Hi
.task {
print("Some work here.")
}
#endif
}
However, when I format this using swiftformat --swiftversion 5.9 --ifdef outdent (version 0.53.2), the code inside the #if has extra indentation in the comment before .task and in part of that block itself:
public struct IfIndentView: View {
public var body: some View {
Text("Hello")
}
#if false
// Hi
.task {
print("Some work here.")
}
#endif
}
I couldn't find a good combination of configuration options to try to fix this, though if I remove the #if altogether, of course it formats correctly.
SwiftFormat is giving me extra indentation when formatting code inside an
#if
block and I don't know why.I'd like to format the following code as shown:
Essentially, I want to disable a block of code using
#if
but keep what's inside the block formatted as usual.However, when I format this using
swiftformat --swiftversion 5.9 --ifdef outdent
(version 0.53.2), the code inside the#if
has extra indentation in the comment before.task
and in part of that block itself:I couldn't find a good combination of configuration options to try to fix this, though if I remove the
#if
altogether, of course it formats correctly.