nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.9k stars 639 forks source link

disabling spaceInsideBrackets spaceInsideBraces trailingSpace consecutiveSpaces seems to have no effect with whitespace between colons #1267

Closed arielelkin closed 2 years ago

arielelkin commented 2 years ago

I'm trying to disable the trimming of whitespace so that spacing between colons is preserved in a specific place, but disabling spaceInsideBrackets spaceInsideBraces trailingSpace consecutiveSpaces seems to have no effect:

 // swiftformat:disable spaceInsideBrackets spaceInsideBraces trailingSpace consecutiveSpaces
class func load(key: KeychainKey) throws -> Data? {
    let query = [
        kSecClass as String       : kSecClassGenericPassword,
        kSecAttrAccount as String : key.asString,
        kSecAttrService as String : service,
        kSecReturnData as String  : kCFBooleanTrue!,
        kSecMatchLimit as String  : kSecMatchLimitOne ] as [String : Any]

result:

class func load(key: KeychainKey) throws -> Data? {
    let query = [
        kSecClass as String: kSecClassGenericPassword,
        kSecAttrAccount as String: key.asString,
        kSecAttrService as String: service,
        kSecReturnData as String: kCFBooleanTrue!,
        kSecMatchLimit as String: kSecMatchLimitOne,
    ] as [String: Any]
nicklockwood commented 2 years ago

Try disabling spaceAroundOperators

arielelkin commented 2 years ago

Thanks for the response. Looks like spaceAroundOperators must be combined with consecutiveSpaces in order for it to work in this instance.