Jintin / Swimat

An Xcode formatter plug-in to format your swift code.
https://jintin.github.io/Swimat/
MIT License
1.65k stars 89 forks source link

Invalid formatting of if statement #201

Closed jaerod95 closed 5 years ago

jaerod95 commented 5 years ago

The following code block is being formatted incorrectly. The correct formatting should be

var states: [TutorialState]?

var currentState: TutorialState? {
    if let states = states, currentStateIndex < states.count, currentStateIndex >= 0 {
        return states[currentStateIndex]
    }
    return nil
}

whereas swimat is formatting it to be:

var states: [TutorialState]?

var currentState: TutorialState? {
    if let states = states, currentStateIndex < states.count, currentStateIndex > = 0 {
        return states[currentStateIndex]
    }
    return nil
}

which causes build issues.

Jintin commented 5 years ago

Currently we don't examine the syntax so currentStateIndex < states.count, currentStateIndex >= 0 this part will be treat as generic <A, B> but next version if you add space between < and A it will break the generic check. We'll see if we can do better in the future. Thanks for report.

Jintin commented 5 years ago

You can try via this release link: https://github.com/Jintin/Swimat/releases/download/v1.6.2/Swimat.zip