Simplify TextHighlights map (#21724)

Remove unnecessary `Option` wrapping.
This commit is contained in:
João Marcos
2024-12-08 20:27:54 -07:00
committed by GitHub
parent 2ce01ead93
commit 55ee72d84a
2 changed files with 12 additions and 12 deletions
+7 -7
View File
@@ -211,7 +211,7 @@ pub struct InlayBufferRows<'a> {
struct HighlightEndpoint {
offset: InlayOffset,
is_start: bool,
tag: Option<TypeId>,
tag: TypeId,
style: HighlightStyle,
}
@@ -239,7 +239,7 @@ pub struct InlayChunks<'a> {
max_output_offset: InlayOffset,
highlight_styles: HighlightStyles,
highlight_endpoints: Peekable<vec::IntoIter<HighlightEndpoint>>,
active_highlights: BTreeMap<Option<TypeId>, HighlightStyle>,
active_highlights: BTreeMap<TypeId, HighlightStyle>,
highlights: Highlights<'a>,
snapshot: &'a InlaySnapshot,
}
@@ -1096,7 +1096,7 @@ impl InlaySnapshot {
&self,
cursor: &mut Cursor<'_, Transform, (InlayOffset, usize)>,
range: &Range<InlayOffset>,
text_highlights: &TreeMap<Option<TypeId>, Arc<(HighlightStyle, Vec<Range<Anchor>>)>>,
text_highlights: &TreeMap<TypeId, Arc<(HighlightStyle, Vec<Range<Anchor>>)>>,
highlight_endpoints: &mut Vec<HighlightEndpoint>,
) {
while cursor.start().0 < range.end {
@@ -1112,7 +1112,7 @@ impl InlaySnapshot {
)))
};
for (tag, text_highlights) in text_highlights.iter() {
for (&tag, text_highlights) in text_highlights.iter() {
let style = text_highlights.0;
let ranges = &text_highlights.1;
@@ -1134,13 +1134,13 @@ impl InlaySnapshot {
highlight_endpoints.push(HighlightEndpoint {
offset: self.to_inlay_offset(range.start.to_offset(&self.buffer)),
is_start: true,
tag: *tag,
tag,
style,
});
highlight_endpoints.push(HighlightEndpoint {
offset: self.to_inlay_offset(range.end.to_offset(&self.buffer)),
is_start: false,
tag: *tag,
tag,
style,
});
}
@@ -1708,7 +1708,7 @@ mod tests {
text_highlight_ranges.sort_by_key(|range| (range.start, Reverse(range.end)));
log::info!("highlighting text ranges {text_highlight_ranges:?}");
text_highlights.insert(
Some(TypeId::of::<()>()),
TypeId::of::<()>(),
Arc::new((
HighlightStyle::default(),
text_highlight_ranges