New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misleading formatting when closure signature is placed on its own line #681
Comments
In my opinion this formatting is much better than the alternatives you suggested. Those just make it look very weird. I prefer to have the Note that I don't use swift-format (I hope to be able to, one day, when it meets my expectations) so I'm not sure what exactly is the current behavior. I'm just mentioning what I think the behavior should be. |
@MahdiBM Inserting a line break after the
The current behavior is the code in the issue. |
I guess this would make a good candidate for an enum-like configurable formatting rule. Then everybody can configure swift-format to their liking. |
Breaking the line before the // margin is here --v
let formattedBytes =
try await withSwiftFormatConfiguration { arg -> Result in
somethingElse()
// but then...
// margin is here --v
let formattedBytes =
try await withSwiftFormatConfiguration {
arg -> LongerResult in
somethingElse() The situation is slightly better for function calls with parenthesized arguments, because you have the option of breaking inside the Looking at other options, there are rare cases where we move the We have a similar issue with wrapped switch x {
case .firstCase, .secondCase, .thirdCase,
.fourthCase:
somethingElse()
} |
Tracked in Apple’s issue tracker as rdar://126948376 |
swift-format produces the following formatting.
This is misleading because it makes
(formatConfigUrl) -> [UInt8] in
look like a statement within the closure. I think it would be better if we either added another indentation level to it or preferred to add the line break at a different location (eg. beforetry
) so that the signature can be on the same line as the{
.This came up in https://github.com/apple/sourcekit-lsp/pull/769/files#r1464107380
The text was updated successfully, but these errors were encountered: