swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.51k stars 10.35k forks source link

[SR-2385] Xcode Swift indentation issue with named arguments #44992

Open swift-ci opened 8 years ago

swift-ci commented 8 years ago
Previous ID SR-2385
Radar None
Original Reporter bnut (JIRA User)
Type Improvement
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Source Tooling | |Labels | Improvement | |Assignee | None | |Priority | Medium | md5: d3e7ff842d08990dd0aa23577ecc0949

Issue Description:

When named arguments are used for multi-line argument definitions the arguments indent such that the label lines up with the argument of the previous line. This leads to ever-increasing indentation in Xcode (all versions as far as I know).

Current output

func test(first a: Int,
                second b: Int,
                       third c: Int,
                             fourth d: Int)
{

}

Expected output

func test(first a: Int,
          second b: Int,
          third c: Int,
          fourth d: Int)
{

}

Better expected output, but doesn't work with very long labels

func test(first a: Int,
         second b: Int,
          third c: Int,
         fourth d: Int)
{

}
swift-ci commented 8 years ago

Comment by Andrew Bennett (JIRA)

@nkcsgexi this may interest you

swift-ci commented 8 years ago

Comment by David Liu (JIRA)

👍 I totally agree with this one particularly with the better expected

nkcsgexi commented 8 years ago

Which Xcode version are you trying on? I think we've fixed this on Xcode 8 beta.

swift-ci commented 8 years ago

Comment by Andrew Bennett (JIRA)

Ah, my apologies!

The formatting I pasted here was in the App Store version (7.3.1). I thought I had also tested in the Xcode 8 beta, but I just tested in latest Xcode 8.0 (beta 6, 8S201h) and it appears to exhibit the "Expected output" behaviour.

I'm happy if you want to close this, although I think it would be improved if it exhibited the "Better expected output" behaviour.

nkcsgexi commented 8 years ago

bnut (JIRA User) No worries : ) The better expected one looks good but it doesn't fit so well into our current implementation of indentation. I'm happy to keep this open as future potential improvement.