Swiftformat: Comments do not get placed after brace when converting to KRN style braces

Created on 23 Aug 2016  路  3Comments  路  Source: nicklockwood/SwiftFormat

Consider this code that follows a _"always braces in new line"_ style with a comment following an if condition-

var networkEnabled = true
if networkEnabled  //We want to enable the UI..
{

}

The tool ends up converting the above code to-

var networkEnabled = true
if networkEnabled  //We want to enable the UI.. {

}

This will result in compiler error as obviously the opening brace after the if is effectively commented out.

All 3 comments

Ooh, nice edge case :-) Thanks!

Fixed in v0.3. Thanks!

Thank you @nicklockwood, now time to use it live in my project.

Was this page helpful?
0 / 5 - 0 ratings