From 68d9681a605c84e7b9ce3de649ed8f7863b508a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ambrus=20T=C3=B3th?= <32463042+tothambrus11@users.noreply.github.com> Date: Thu, 7 May 2026 10:20:24 +0300 Subject: [PATCH 1/2] Update contains method to include start position (#34) --- Sources/LanguageServerProtocol/BasicStructures.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/LanguageServerProtocol/BasicStructures.swift b/Sources/LanguageServerProtocol/BasicStructures.swift index d1ef443..b0bd445 100644 --- a/Sources/LanguageServerProtocol/BasicStructures.swift +++ b/Sources/LanguageServerProtocol/BasicStructures.swift @@ -65,7 +65,7 @@ public struct LSPRange: Codable, Hashable, Sendable { } public func contains(_ position: Position) -> Bool { - return position > start && position < end + return position >= start && position < end } public func intersects(_ other: LSPRange) -> Bool { From 135c887ba550bb82feddbafd7dd3cdd1faf0b5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ambrus=20T=C3=B3th?= <32463042+tothambrus11@users.noreply.github.com> Date: Thu, 7 May 2026 10:30:45 +0300 Subject: [PATCH 2/2] Add documentation to `contains` and `intersects` methods of LSPRange --- Sources/LanguageServerProtocol/BasicStructures.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/LanguageServerProtocol/BasicStructures.swift b/Sources/LanguageServerProtocol/BasicStructures.swift index b0bd445..b13c12a 100644 --- a/Sources/LanguageServerProtocol/BasicStructures.swift +++ b/Sources/LanguageServerProtocol/BasicStructures.swift @@ -64,10 +64,12 @@ public struct LSPRange: Codable, Hashable, Sendable { self.end = other.upperBound } + /// Returns whether the position is in [start, end). public func contains(_ position: Position) -> Bool { return position >= start && position < end } + /// Returns true iff there is any position contained both in `self` and `other`. public func intersects(_ other: LSPRange) -> Bool { return contains(other.start) || contains(other.end) }