From ac7ab23bdf95c69db04a366c22b551c366e70beb Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Thu, 27 Jun 2024 17:05:56 +0200 Subject: [PATCH] Fix a build issue in swift-format --- Sources/SwiftFormat/API/Selection.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sources/SwiftFormat/API/Selection.swift b/Sources/SwiftFormat/API/Selection.swift index 9ea599db3..5fcccaac0 100644 --- a/Sources/SwiftFormat/API/Selection.swift +++ b/Sources/SwiftFormat/API/Selection.swift @@ -49,6 +49,14 @@ public enum Selection { } } +extension Range { + // Returns `true` if the intersection between this range and `other` is non-empty or if the two ranges are directly + /// adjacent to each other. + public func overlapsOrTouches(_ other: Range) -> Bool { + return self.upperBound >= other.lowerBound && self.lowerBound <= other.upperBound + } +} + public extension Syntax { /// - Returns: `true` if the node is _completely_ inside any range in the selection