Xcode Swift computed property get/set indentation is awkward
| Originator: | kristopherdjohnson | ||
| Number: | rdar://17769362 | Date Originated: | 22-Jul-2014 05:55 PM |
| Status: | Duplicate/16747499 | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 6.0 (6A267n) |
| Classification: | UI/Usability | Reproducible: | Always |
Summary:
The default indentation enforced by Xcode for a computed property is not what many (most?) developers would want.
The indentation looks like this:
class Foo {
var getOnlyValue: Int {
return 0
}
var gettableAndSettableValue: Int {
get {
return 1
}
set (newValue) {
// whatever
}
}
}
Here are the complaints:
- The "return 0" in the first property should be indented. Having it flush with the lines above and below makes it difficult to see the code's structure.
- The indentation of "get" and "set" in the second property don't look too bad, as the content of each is indented, but it is awkward that the two closing braces are in the same column.
I assume this indentation style was implemented with a desire to prevent deep nesting of get/set properties, but in general such code will not be deeply nested, and in any event readability/scannability should be more important than conserving horizontal space.
Developers can manually reindent the code the way they wish, but Xcode will change it back to its preferred style if the code is copied and pasted.
Steps to Reproduce:
Copy and paste this text into Xcode playground or editor with Swift code:
class Foo {
var getOnlyValue: Int {
return 0
}
var gettableAndSettableValue: Int {
get {
return 1
}
set (newValue) {
// whatever
}
}
}
Expected Results:
Should have this text pasted:
class Foo {
var getOnlyValue: Int {
return 0
}
var gettableAndSettableValue: Int {
get {
return 1
}
set (newValue) {
// whatever
}
}
}
Actual Results:
Have text with this indentation:
class Foo {
var getOnlyValue: Int {
return 0
}
var gettableAndSettableValue: Int {
get {
return 1
}
set (newValue) {
// whatever
}
}
}
Version:
Version 6.0 (6A267n)
Notes:
Configuration:
Attachments:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!