Skip to content

Commit

Permalink
Update for 0.47.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Oct 26, 2020
1 parent 5833b62 commit b0e19d0
Show file tree
Hide file tree
Showing 43 changed files with 96 additions and 83 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## [0.47.1](https://github.com/nicklockwood/SwiftFormat/releases/tag/0.47.1) (2020-1026)

- Fixed a crash when using the `fileHeader` rule
- Fixed occasional out-of-bounds crash in `markTypes` rule
- Fixed bug where `wrapArguments` rule unexpectedly indented blank lines inside braces or brackets
- Added `--wrapconditions` option for controlling how multiline conditional statements are wrapped
- Unicode whitespace characters other than space and tab are no longer treated as an error
- Indenting of `else` clauses now matches Xcode 12

## [0.47.0](https://github.com/nicklockwood/SwiftFormat/releases/tag/0.47.0) (2020-10-14)

- Indenting of wrapped `if`, `guard`, `while`, etc. now matches Xcode 12 behavior
Expand Down
Binary file modified CommandLineTool/swiftformat
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.47.0</string>
<string>0.47.1</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>0.46.3</string>
<string>0.47.1</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@
</data>
<key>Resources/Assets.car</key>
<data>
YiheLpyp+SRLXxFU721UYx8oI6c=
i1nQ3AP7q1o1l0oMbDyIhtIAJQk=
</data>
<key>Resources/Base.lproj/Main.storyboardc/9ZR-Qg-hHT-view-iDF-FY-6tf.nib</key>
<data>
NgkuD0ekbF0F8PCXGo2XyDdQEZ4=
kowUfb8NOlvZ/sRjcrTyeMboocM=
</data>
<key>Resources/Base.lproj/Main.storyboardc/Info.plist</key>
<data>
+/DJ7okKXSwZ02uqruRsLmLrVME=
KUCRUWQFh8eD4elreENasVZ/OfQ=
</data>
<key>Resources/Base.lproj/Main.storyboardc/MainMenu.nib</key>
<data>
lI7KbQws4PaWE18pL0llqYlccT0=
/IK4mLu8nZ8UHDalgJeEPYG1o+s=
</data>
<key>Resources/Base.lproj/Main.storyboardc/MainWindowTabViewController.nib</key>
<data>
sWeCbAsRLvNYKtIy6w6ivu/7Qpk=
YqQv7N0aMR5YyUmpXUxC1GxCUQI=
</data>
<key>Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib</key>
<data>
Zdo9GV43c2YGAWk8LB9vj4kOsAg=
m2fGJDX3cbUptpSqAhNtstaP2pE=
</data>
<key>Resources/Base.lproj/Main.storyboardc/RulesViewController.nib</key>
<data>
beYTI7gNKts02jpMY7lcElpKxsk=
a+oButdBcjZYpFqVc9L2gnUzMmo=
</data>
<key>Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib</key>
<data>
Expand Down Expand Up @@ -182,7 +182,7 @@
<dict>
<key>cdhash</key>
<data>
Z+z+6QsyriEW62UtZKRx4w/hNm8=
TGpNcIgdX8cYOIDwJy+lN0t2wn8=
</data>
<key>requirement</key>
<string>anchor apple generic and identifier "com.charcoaldesign.SwiftFormat-for-Xcode.SourceEditorExtension" and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = "8VQKF583ED")</string>
Expand All @@ -198,49 +198,49 @@
<dict>
<key>hash2</key>
<data>
GYXZ11g7/0ggejEJ1zVPKm8+O+vtpstht2WvFXURoag=
FzsRYWi6ndNZ2i1IkX6fR+McgX+EpFYQ59t0CNakagM=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/9ZR-Qg-hHT-view-iDF-FY-6tf.nib</key>
<dict>
<key>hash2</key>
<data>
SFlU7n9v5kte+wKrebcdyk34TT5YjcOgi20SozeVsAE=
MASJ47hYmULflnz3f04VpUQcH41xXxXR9QdZNlicr5g=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/Info.plist</key>
<dict>
<key>hash2</key>
<data>
or34ef1CtY0IAqy8rCQrmLYSv5sn6jdShMx4sLw+9s4=
72g9if/5GQgNjZE1lyyNTey8xsQMQBqmnYtFFdPN7uA=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/MainMenu.nib</key>
<dict>
<key>hash2</key>
<data>
qrLtyVyZiN2qpsNs1XdrvF9DrmXStoXqUyrcRkYL+WQ=
2ysNGqPqA/oHYQsJcydFXPomiKgXbo7A1WjNOFC4IWY=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/MainWindowTabViewController.nib</key>
<dict>
<key>hash2</key>
<data>
0niOKWSTJYKDJD/YK454D67ykqdcOV63t7geVMDXWcg=
CHMsfr2gTXAElfLtiHKfbEozKfv4HNs0hdPteTX9ioE=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib</key>
<dict>
<key>hash2</key>
<data>
22rpMYPNyrK/2QRHNpkFjy8pphfvIWoc+SmS6USZBB4=
xQCDfgCSEnK+k+A+nPIphpZZZfvHn1e5wGJY6NZDYGw=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/RulesViewController.nib</key>
<dict>
<key>hash2</key>
<data>
LsMenOnAUxX3uVz8bsmLY81eVMjvyPE5PJrkBheicG0=
1UdR4Xbtob7O23ePfChjgBzROBivYunMYAl4V7RjJl8=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib</key>
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,9 @@ Q. I don't want to be surprised by new rules added when I upgrade SwiftFormat. H
Known issues
---------------
* When running a version of SwiftFormat built using Xcode 10.2 on macOS 10.14.3 or earlier, you may experience a crash with the error "dyld: Library not loaded: @rpath/libswiftCore.dylib". To fix this, you need to install the [Swift 5 Runtime Support for Command Line Tools](https://support.apple.com/kb/DL1998). These tools are included by default in macOS 10.14.4 and later.
* When using the `initCoderUnavailable` rule, if an `init` that is marked as unavailable is overridden elsewhere in the program then it will cause a compilation error. The recommended workaround is to remove the override (which shouldn't affect the program behavior if the init was really unused) or use the `// swiftformat:disable:next initCoderUnavailable` comment directive to disable the rule for the overridden init (or just disable the `initCoderUnavailable` rule completely).
* When using the `extensionAccessControl` rule with the `--extensionacl on-extension` option, if you have public methods defined on an internal or private type, the resultant public extension will no longer compile. The recommended solution is to manually remove the `public` modifier (this won't change the program behavior) or disable the `extensionAccessControl` rule.
* When using the `preferKeyPath` rule, conversion of `compactMap { $0.foo }` to `compactMap(\.foo)` will result in code that fails to compile if `foo` is not an `Optional` property. This is due to a difference in the way that Swift handles type inference for closures vs keyPaths, as discussed [here](https://bugs.swift.org/browse/SR-13347). The recommended workaround is to replace `compactMap()` with `map()` in these cases, which will not change the behavior of the code.
Expand All @@ -761,6 +763,8 @@ Known issues
* If a file begins with a comment, the `stripHeaders` rule will remove it if it is followed by a blank line. To avoid this, make sure that the first comment is directly followed by a line of code.
* When running a version of SwiftFormat built using Xcode 10.2 on macOS 10.14.3 or earlier, you may experience a crash with the error "dyld: Library not loaded: @rpath/libswiftCore.dylib". To fix this, you need to install the [Swift 5 Runtime Support for Command Line Tools](https://support.apple.com/kb/DL1998). These tools are included by default in macOS 10.14.4 and later.
* When running on Linux, the `--symlinks` option has no effect, and some of the `fileHeader` placeholders are not supported.
Expand Down
4 changes: 2 additions & 2 deletions Sources/Formatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Formatter.swift
// SwiftFormat
//
// Version 0.47.0
// Version 0.47.1
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Nick Lockwood
Expand Down Expand Up @@ -419,7 +419,7 @@ public extension Formatter {
return i
}
} else if token == .endOfScope("case") || token == .endOfScope("default"),
scopeStack.last == .startOfScope("#if")
scopeStack.last == .startOfScope("#if")
{
continue
} else if scopeStack.isEmpty, matches(token) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/FormattingHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ extension Formatter {
insert(.space(" "), at: index + 1)
}
} else if tokenInsideParenRequiresSpacing(at: index - 1),
tokenOutsideParenRequiresSpacing(at: index + 1)
tokenOutsideParenRequiresSpacing(at: index + 1)
{
// Need to insert one
insert(.space(" "), at: index + 1)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Globs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func matchGlobs(_ globs: [Glob], in directory: String) -> [URL] {
if globs.contains(where: { $0.matches(path) }) {
urls.append(url)
} else if manager.fileExists(atPath: path, isDirectory: &isDirectory),
isDirectory.boolValue
isDirectory.boolValue
{
enumerate(url)
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Inference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ private struct Inference {
{
noSpaceOperators.insert(pair.1)
} else if noSpaceOperators.contains(pair.1),
!noSpaceOperators.contains(pair.0),
!operators.contains(pair.0)
!noSpaceOperators.contains(pair.0),
!operators.contains(pair.0)
{
noSpaceOperators.insert(pair.0)
}
Expand Down Expand Up @@ -977,7 +977,7 @@ private struct Inference {
if formatter.next(.nonSpaceOrCommentOrLinebreak, after: nextIndex) == .operator("=", .infix) {
initUnremoved += 1
} else if let scopeEnd = formatter.index(of: .endOfScope(")"), after: nextIndex),
formatter.next(.nonSpaceOrCommentOrLinebreak, after: scopeEnd) == .operator("=", .infix)
formatter.next(.nonSpaceOrCommentOrLinebreak, after: scopeEnd) == .operator("=", .infix)
{
initUnremoved += 1
} else {
Expand Down Expand Up @@ -1032,7 +1032,7 @@ private struct Inference {
if formatter.next(.nonSpaceOrCommentOrLinebreak, after: index) == .operator("=", .infix) {
initRemoved += 1
} else if let scopeEnd = formatter.index(of: .endOfScope(")"), after: index),
formatter.next(.nonSpaceOrCommentOrLinebreak, after: scopeEnd) == .operator("=", .infix)
formatter.next(.nonSpaceOrCommentOrLinebreak, after: scopeEnd) == .operator("=", .infix)
{
initRemoved += 1
} else {
Expand Down
26 changes: 13 additions & 13 deletions Sources/ParsingHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1165,10 +1165,10 @@ extension Formatter {
// `isDeclarationTypeKeyword` in the declaration's opening sequence (up until the `{`).
// - This makes sure that we correctly identify `class func` declarations as being functions.
else if let endOfDeclarationOpeningSequence = parser.index(after: -1, where: { $0 == .startOfScope("{") }),
let lastDeclarationTypeKeywordIndex = parser.lastIndex(
in: 0 ..< endOfDeclarationOpeningSequence,
where: { $0.isDeclarationTypeKeyword }
)
let lastDeclarationTypeKeywordIndex = parser.lastIndex(
in: 0 ..< endOfDeclarationOpeningSequence,
where: { $0.isDeclarationTypeKeyword }
)
{
declarationTypeKeywordIndex = lastDeclarationTypeKeywordIndex
declarationKeyword = parser.tokens[lastDeclarationTypeKeywordIndex].string
Expand Down Expand Up @@ -1344,9 +1344,9 @@ extension Formatter {
// If this declaration represents a conditional compilation block,
// we also have to parse its inner declarations.
else if declaration.keyword == "#if",
let declarationTypeKeywordIndex = declarationParser
.index(after: -1, where: { $0.string == declaration.keyword }),
let endOfBody = declarationParser.endOfScope(at: declarationTypeKeywordIndex)
let declarationTypeKeywordIndex = declarationParser
.index(after: -1, where: { $0.string == declaration.keyword }),
let endOfBody = declarationParser.endOfScope(at: declarationTypeKeywordIndex)
{
let startOfBody = declarationParser.endOfLine(at: declarationTypeKeywordIndex)
let (startTokens, bodyDeclarations, endTokens) = parseBody(in: startOfBody ... endOfBody)
Expand Down Expand Up @@ -1512,12 +1512,12 @@ extension Formatter {
guard let commaIndex = self.index(of: .nonSpaceOrCommentOrLinebreak, before: index + 1, if: {
$0 == .delimiter(",")
}), case let lineStart = startOfLine(at: commaIndex),
let firstToken = self.index(of: .nonSpace, after: lineStart - 1),
let keywordIndex = lastIndex(in: firstToken ..< commaIndex, where: {
[.keyword("if"), .keyword("guard"), .keyword("while")].contains($0)
}) ?? lastIndex(in: firstToken ..< commaIndex, where: {
[.keyword("let"), .keyword("var"), .keyword("case")].contains($0)
})
let firstToken = self.index(of: .nonSpace, after: lineStart - 1),
let keywordIndex = lastIndex(in: firstToken ..< commaIndex, where: {
[.keyword("if"), .keyword("guard"), .keyword("while")].contains($0)
}) ?? lastIndex(in: firstToken ..< commaIndex, where: {
[.keyword("let"), .keyword("var"), .keyword("case")].contains($0)
})
else {
return options.indent
}
Expand Down
Loading

0 comments on commit b0e19d0

Please sign in to comment.