@@ -152,6 +152,12 @@ open class BasicFormat: SyntaxRewriter {
152
152
if let keyPath = getKeyPath ( token) , let requiresLeadingSpace = requiresLeadingSpace ( keyPath) {
153
153
return requiresLeadingSpace
154
154
}
155
+ switch ( token. previousToken ( viewMode: . sourceAccurate) ? . tokenKind, token. tokenKind) {
156
+ case ( . leftParen, . leftBrace) : // Ensures there is not a space in `.map({ $0.foo })`
157
+ return false
158
+ default :
159
+ break
160
+ }
155
161
switch token. tokenKind {
156
162
case . leftBrace:
157
163
return true
@@ -202,15 +208,15 @@ open class BasicFormat: SyntaxRewriter {
202
208
return requiresTrailingSpace
203
209
}
204
210
switch ( token. tokenKind, token. nextToken ( viewMode: . sourceAccurate) ? . tokenKind) {
205
- case ( . exclamationMark, . leftParen) , // Ensures there is not space in `myOptionalClosure!()`
206
- ( . exclamationMark, . period) , // Ensures there is not space in `myOptionalBar!.foo()`
207
- ( . keyword( . as) , . exclamationMark) , // Ensures there is not space in `as!`
208
- ( . keyword( . as) , . postfixQuestionMark) , // Ensures there is not space in `as?`
209
- ( . keyword( . try ) , . exclamationMark) , // Ensures there is not space in `try!`
210
- ( . keyword( . try ) , . postfixQuestionMark) , // Ensures there is not space in `try?`:
211
- ( . postfixQuestionMark, . leftParen) , // Ensures there is not space in `init?()` or `myOptionalClosure?()`s
212
- ( . postfixQuestionMark, . rightAngle) , // Ensures there is not space in `ContiguousArray<RawSyntax?>`
213
- ( . postfixQuestionMark, . rightParen) : // Ensures there is not space in `myOptionalClosure?()`
211
+ case ( . exclamationMark, . leftParen) , // Ensures there is not a space in `myOptionalClosure!()`
212
+ ( . exclamationMark, . period) , // Ensures there is not a space in `myOptionalBar!.foo()`
213
+ ( . keyword( . as) , . exclamationMark) , // Ensures there is not a space in `as!`
214
+ ( . keyword( . as) , . postfixQuestionMark) , // Ensures there is not a space in `as?`
215
+ ( . keyword( . try ) , . exclamationMark) , // Ensures there is not a space in `try!`
216
+ ( . keyword( . try ) , . postfixQuestionMark) , // Ensures there is not a space in `try?`:
217
+ ( . postfixQuestionMark, . leftParen) , // Ensures there is not a space in `init?()` or `myOptionalClosure?()`s
218
+ ( . postfixQuestionMark, . rightAngle) , // Ensures there is not a space in `ContiguousArray<RawSyntax?>`
219
+ ( . postfixQuestionMark, . rightParen) : // Ensures there is not a space in `myOptionalClosure?()`
214
220
return false
215
221
default :
216
222
break
0 commit comments