diff --git a/CommandLineTool/main.swift b/CommandLineTool/main.swift index aeabae782..ead20a721 100644 --- a/CommandLineTool/main.swift +++ b/CommandLineTool/main.swift @@ -2,7 +2,7 @@ // main.swift // SwiftFormat // -// Version 0.11.2 +// Version 0.11.3 // // Created by Nick Lockwood on 12/08/2016. // Copyright 2016 Charcoal Design @@ -33,7 +33,7 @@ import Foundation -let version = "0.11.2" +let version = "0.11.3" func showHelp() { print("swiftformat, version \(version)") diff --git a/CommandLineTool/swiftformat b/CommandLineTool/swiftformat index f7e0ca348..22ea6220f 100755 Binary files a/CommandLineTool/swiftformat and b/CommandLineTool/swiftformat differ diff --git a/LICENCE.md b/LICENCE.md index 3f983a7d4..a98b89eb9 100755 --- a/LICENCE.md +++ b/LICENCE.md @@ -1,6 +1,6 @@ SwiftFormat -Version 0.11.2, October 4th, 2016 +Version 0.11.3, October 4th, 2016 Copyright (c) 2016 Nick Lockwood diff --git a/README.md b/README.md index 705a39c86..b58f7a353 100644 --- a/README.md +++ b/README.md @@ -403,6 +403,11 @@ What's next? Release notes ---------------- +Version 0.11.3 + +- Fixed spacing between closure capture list and arguments +- Fixed incorrect indenting of closures after and `if` statement, and other braced clauses + Version 0.11.2 - Fixed incorrect indenting of closures inside `for` loops, and other braced clauses diff --git a/SwiftFormat/Formatter.swift b/SwiftFormat/Formatter.swift index 77d090484..bd9b7704d 100644 --- a/SwiftFormat/Formatter.swift +++ b/SwiftFormat/Formatter.swift @@ -2,7 +2,7 @@ // Formatter.swift // SwiftFormat // -// Version 0.11.2 +// Version 0.11.3 // // Created by Nick Lockwood on 12/08/2016. // Copyright 2016 Charcoal Design diff --git a/SwiftFormat/Rules.swift b/SwiftFormat/Rules.swift index 565dd2c75..7a39baf36 100644 --- a/SwiftFormat/Rules.swift +++ b/SwiftFormat/Rules.swift @@ -2,7 +2,7 @@ // Rules.swift // SwiftFormat // -// Version 0.11.2 +// Version 0.11.3 // // Created by Nick Lockwood on 12/08/2016. // Copyright 2016 Charcoal Design @@ -83,7 +83,7 @@ public func spaceAroundParens(_ formatter: Formatter) { } return true } - + formatter.forEachToken("(") { i, token in guard let previousToken = formatter.tokenAtIndex(i - 1) else { return @@ -925,7 +925,7 @@ public func indent(_ formatter: Formatter) { while let token = formatter.tokenAtIndex(i) { switch token.type { case .identifier: - if ["if", "for", "while", "catch", "switch" /* TODO: get/set/didSet */ ].contains(token.string) { + if ["if", "for", "while", "catch", "switch", "guard" /* TODO: get/set/didSet */ ].contains(token.string) { // Check that it's actually a keyword and not a member property or enum value return formatter.previousNonWhitespaceOrCommentOrLinebreakToken(fromIndex: i)?.string == "." } diff --git a/SwiftFormat/SwiftFormat.h b/SwiftFormat/SwiftFormat.h index fc1eb670c..49998916e 100644 --- a/SwiftFormat/SwiftFormat.h +++ b/SwiftFormat/SwiftFormat.h @@ -2,7 +2,7 @@ // SwiftFormat.h // SwiftFormat // -// Version 0.11.2 +// Version 0.11.3 // // Created by Nick Lockwood on 12/08/2016. // Copyright 2016 Charcoal Design diff --git a/SwiftFormat/SwiftFormat.swift b/SwiftFormat/SwiftFormat.swift index d344a86a1..242731ba3 100644 --- a/SwiftFormat/SwiftFormat.swift +++ b/SwiftFormat/SwiftFormat.swift @@ -2,7 +2,7 @@ // SwiftFormat.swift // SwiftFormat // -// Version 0.11.2 +// Version 0.11.3 // // Created by Nick Lockwood on 12/08/2016. // Copyright 2016 Charcoal Design diff --git a/SwiftFormat/Tokenizer.swift b/SwiftFormat/Tokenizer.swift index 135611c4d..b36973cde 100644 --- a/SwiftFormat/Tokenizer.swift +++ b/SwiftFormat/Tokenizer.swift @@ -2,7 +2,7 @@ // Tokenizer.swift // SwiftFormat // -// Version 0.11.2 +// Version 0.11.3 // // Created by Nick Lockwood on 11/08/2016. // Copyright 2016 Charcoal Design diff --git a/SwiftFormatTests/RulesTests.swift b/SwiftFormatTests/RulesTests.swift index e4804808b..2eae1e4d7 100644 --- a/SwiftFormatTests/RulesTests.swift +++ b/SwiftFormatTests/RulesTests.swift @@ -112,14 +112,14 @@ class RulesTests: XCTestCase { XCTAssertEqual(try! format(input, rules: [spaceAroundParens]), output) XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n") } - + func testNoRemoveSpaceBetweenCaptureListAndArguments() { let input = "{ [weak self] (foo) in }" let output = "{ [weak self] (foo) in }" XCTAssertEqual(try! format(input, rules: [spaceAroundParens]), output) XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n") } - + func testAddSpaceBetweenCaptureListAndArguments() { let input = "{ [weak self](foo) in }" let output = "{ [weak self] (foo) in }" @@ -1370,49 +1370,49 @@ class RulesTests: XCTestCase { XCTAssertEqual(try! format(input, rules: [indent]), output) XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n") } - + func testNestedWrappedIfIndents() { let input = "if foo {\nif bar &&\n(baz ||\nquux) {\nfoo()\n}\n}" let output = "if foo {\n if bar &&\n (baz ||\n quux) {\n foo()\n }\n}" XCTAssertEqual(try! format(input, rules: [indent]), output) XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n") } - + func testWrappedEnumThatLooksLikeIf() { let input = "foo &&\n bar.if {\nfoo()\n}" let output = "foo &&\n bar.if {\n foo()\n }" XCTAssertEqual(try! format(input, rules: [indent]), output) XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n") } - + func testChainedClosureIndents() { let input = "foo\n.bar {\nbaz()\n}\n.bar {\nbaz()\n}" let output = "foo\n .bar {\n baz()\n }\n .bar {\n baz()\n }" XCTAssertEqual(try! format(input, rules: [indent]), output) XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n") } - + func testChainedFunctionsInsideIf() { let input = "if foo {\nreturn bar()\n.baz()\n}" let output = "if foo {\n return bar()\n .baz()\n}" XCTAssertEqual(try! format(input, rules: [indent]), output) XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n") } - + func testChainedFunctionsInsideForLoop() { let input = "for x in y {\nfoo\n.bar {\nbaz()\n}\n.quux()\n}" let output = "for x in y {\n foo\n .bar {\n baz()\n }\n .quux()\n}" XCTAssertEqual(try! format(input, rules: [indent]), output) XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n") } - + func testChainedFunctionsAfterAnIfStatement() { let input = "if foo {}\nbar\n.baz {\n}\n.quux()" let output = "if foo {}\nbar\n .baz {\n }\n .quux()" XCTAssertEqual(try! format(input, rules: [indent]), output) XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n") } - + func testIndentInsideWrappedIfStatementWithClosureCondition() { let input = "if foo({ 1 }) ||\nbar {\nbaz()\n}" let output = "if foo({ 1 }) ||\n bar {\n baz()\n}"