Coding Style Swift Reformatting - No linebrake for simple methods
Answered
Dear all,
After reformatting, I would like to keep simple methods in one line, after the braces start. Setting a new line after each method name works.
In CLion that worked.
Thank you!
Please sign in to leave a comment.
Hi Peter.
What AppCode version are you using? Do you have the option enabled in Preferences | Editor | Code Style | Swift | Wrapping and Braces ?
I do have it and it's marked, but it does not keep things in one line!
So I would like
1.) Put braces in a new line
2.) But keep it, if it is a simple function
From the preference this is what I expect, but it is still doing the linebrake.
Which version? Should be working fine in AppCode 2017.2 and newer.
Version 2017.3.1
Thanks for the screenshot, it actually has shown where the problem is - setting for Braces placement | In methods and functions | Next line if wrapped is affecting formatting behavior. When setting it to End of line formatting for simple methods works as expected. Please vote & watch OC-13794.
I am aware that this combination works (that's what I meant in the second sentence of the first post). So I can either have them in one line OR have braces always in the next line. Not both at the same time?
The first picture shows, what I would like to have. So "Keep when reformating" is not keeping this configuration.
BTW. What means "if wrapped"? Wrapped by other braces e.g. as method in a class?
Thank you!
Peter,
"if wrapped" for a declaration means that declaration is multiline, e.g. when function has several parameters and each one is placed on a separate line:
>So I can either have them in one line OR have braces always in the next line. Not both at the same time?
No, the combination should work as you expect it to work (i.e. simple methods should be placed on one line regardless of the selected "Braces placement" option). But it's broken due to OC-13794, as I've mentioned above. So, after the fix it should be working fine for your setup.