nicklockwood / SwiftFormat

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

Block is recognized as single line even when there is code after return in the first line #822

Closed Cyberbeni closed 3 years ago

Cyberbeni commented 3 years ago
class PdfAboveKeyboardSearchView: UITextField {
    lazy var searchbar = UISearchBar()
    lazy var _inputAccessoryView: UIView = {
        return searchbar
        let toolbar = UIToolbar()
        toolbar.items = [.fixedSpace(10), UIBarButtonItem(customView: searchbar), .fixedSpace(10)]
        toolbar.sizeToFit()
        return toolbar
    }()
}

In this case return gets removed on line 4 resulting in Expression resolves to an unused property swiftformat version: 0.47.5 (I'm trying to figure out how to make the searchbar inside the input accessory toolbar fit the remaining size)

nicklockwood commented 3 years ago

@Cyberbeni thanks for reporting this. I'll fix it, but for now a workaround would be to comment out the code after the first return.

nicklockwood commented 3 years ago

@Cyberbeni fixed in 0.47.6