mirror of
https://github.com/nicklockwood/SwiftFormat.git
synced 2026-06-16 10:34:34 +00:00
Handle edge case for startOfScope helper
This commit is contained in:
@@ -141,7 +141,14 @@ public extension Formatter {
|
||||
|
||||
/// Returns the index of the starting token for the current scope
|
||||
func startOfScope(at index: Int) -> Int? {
|
||||
self.index(of: .startOfScope, before: index)
|
||||
self.index(of: .startOfScope, before: index).flatMap {
|
||||
if [.startOfScope("//"), .startOfScope("#!")].contains(tokens[$0]),
|
||||
self.index(of: .linebreak, after: $0) ?? index < index
|
||||
{
|
||||
return nil
|
||||
}
|
||||
return $0
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the index of the ending token for the current scope
|
||||
|
||||
Reference in New Issue
Block a user