Skip to content

Commit e3bc561

Browse files
committed
Don’t fatalError when calling splitToSingleLineRanges on a range that exceeds past the document
1 parent f41feb7 commit e3bc561

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sources/SourceKitLSP/Swift/SyntaxHighlightingTokenParser.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ struct SyntaxHighlightingTokenParser {
206206
}
207207
}
208208

209-
extension Range where Bound == Position {
209+
extension Range<Position> {
210210
/// Splits a potentially multi-line range to multiple single-line ranges.
211211
func splitToSingleLineRanges(in snapshot: DocumentSnapshot) -> [Self] {
212212
if isEmpty {
@@ -220,7 +220,8 @@ extension Range where Bound == Position {
220220
guard let startIndex = snapshot.index(of: lowerBound),
221221
let endIndex = snapshot.index(of: upperBound)
222222
else {
223-
fatalError("Range \(self) reaches outside of the document")
223+
logger.fault("Range \(self) reaches outside of the document")
224+
return [self]
224225
}
225226

226227
let text = snapshot.text[startIndex..<endIndex]

0 commit comments

Comments
 (0)