File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
CodeEdit/Features/LSP/Features/SemanticTokens Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments