Skip to content

Commit 8667215

Browse files
Merge branch 'CodeEditApp:main' into lsp-install-ux
2 parents 7ee6d87 + f6f2b80 commit 8667215

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

CodeEdit/Features/LSP/Features/SemanticTokens/SemanticTokenHighlightProvider.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,20 @@ final class SemanticTokenHighlightProvider<
166166
let rawTokens = storage.getTokensFor(range: lspRange)
167167
let highlights = tokenMap
168168
.decode(tokens: rawTokens, using: textView)
169-
.filter({ $0.capture != nil || !$0.modifiers.isEmpty })
169+
.compactMap { highlightRange -> HighlightRange? in
170+
// Filter out empty ranges
171+
guard highlightRange.capture != nil || !highlightRange.modifiers.isEmpty,
172+
// Clamp the highlight range to the queried range.
173+
let intersection = highlightRange.range.intersection(range),
174+
intersection.isEmpty == false else {
175+
return nil
176+
}
177+
return HighlightRange(
178+
range: intersection,
179+
capture: highlightRange.capture,
180+
modifiers: highlightRange.modifiers
181+
)
182+
}
170183
completion(.success(highlights))
171184
}
172185
}

0 commit comments

Comments
 (0)