Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Remove useless background highlights code
Kirill Bulatov9b43acfc8870
diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rsindex 88cdd9ac366..20e2a2a266f 100644--- a/crates/editor/src/display_map.rs+++ b/crates/editor/src/display_map.rs@@ -308,9 +308,6 @@ impl DisplayMap {pub struct Highlights<'a> {pub text_highlights: Option<&'a TextHighlights>,pub inlay_highlights: Option<&'a InlayHighlights>,- // TODO kb remove, backgrounds are not handled in the *Map codegi- pub inlay_background_highlights:- Option<TreeMap<Option<TypeId>, Arc<(HighlightStyle, &'a [InlayHighlight])>>>,pub inlay_highlight_style: Option<HighlightStyle>,pub suggestion_highlight_style: Option<HighlightStyle>,}@@ -482,9 +479,6 @@ impl DisplaySnapshot {&'a self,display_rows: Range<u32>,language_aware: bool,- inlay_background_highlights: Option<- TreeMap<Option<TypeId>, Arc<(HighlightStyle, &'a [InlayHighlight])>>,- >,inlay_highlight_style: Option<HighlightStyle>,suggestion_highlight_style: Option<HighlightStyle>,) -> DisplayChunks<'_> {@@ -494,7 +488,6 @@ impl DisplaySnapshot {Highlights {text_highlights: Some(&self.text_highlights),inlay_highlights: Some(&self.inlay_highlights),- inlay_background_highlights,inlay_highlight_style,suggestion_highlight_style,},@@ -1714,7 +1707,7 @@ pub mod tests {) -> Vec<(String, Option<Color>, Option<Color>)> {let snapshot = map.update(cx, |map, cx| map.snapshot(cx));let mut chunks: Vec<(String, Option<Color>, Option<Color>)> = Vec::new();- for chunk in snapshot.chunks(rows, true, None, None, None) {+ for chunk in snapshot.chunks(rows, true, None, None) {let syntax_color = chunk.syntax_highlight_id.and_then(|id| id.style(theme)?.color);diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 67560b1b033..e61a41f3efa 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -7823,6 +7823,7 @@ impl Editor {color_fetcher: fn(&Theme) -> Color,cx: &mut ViewContext<Self>,) {+ // TODO: no actual highlights happen for inlays currently, find a way to do thatself.inlay_background_highlights.insert(Some(TypeId::of::<T>()), (color_fetcher, ranges));cx.notify();diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex bc3ca9f7b13..b7e34fda537 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -54,7 +54,6 @@ use std::{ops::Range,sync::Arc,};-use sum_tree::TreeMap;use text::Point;use workspace::item::Item;@@ -1548,7 +1547,6 @@ impl EditorElement {&mut self,rows: Range<u32>,line_number_layouts: &[Option<Line>],- editor: &mut Editor,snapshot: &EditorSnapshot,cx: &ViewContext<Editor>,) -> Vec<LineWithInvisibles> {@@ -1593,28 +1591,10 @@ impl EditorElement {.collect()} else {let style = &self.style;- let theme = theme::current(cx);- let inlay_background_highlights =- TreeMap::from_ordered_entries(editor.inlay_background_highlights.iter().map(- |(type_id, (color_fetcher, ranges))| {- let color = Some(color_fetcher(&theme));- (- *type_id,- Arc::new((- HighlightStyle {- color,- ..HighlightStyle::default()- },- ranges.as_slice(),- )),- )- },- ));let chunks = snapshot.chunks(rows.clone(),true,- Some(inlay_background_highlights),Some(style.theme.hint),Some(style.theme.suggestion),)@@ -2375,13 +2355,8 @@ impl Element<Editor> for EditorElement {let scrollbar_row_range = scroll_position.y()..(scroll_position.y() + height_in_lines);let mut max_visible_line_width = 0.0;- let line_layouts = self.layout_lines(- start_row..end_row,- &line_number_layouts,- editor,- &snapshot,- cx,- );+ let line_layouts =+ self.layout_lines(start_row..end_row, &line_number_layouts, &snapshot, cx);for line_with_invisibles in &line_layouts {if line_with_invisibles.line.width() > max_visible_line_width {max_visible_line_width = line_with_invisibles.line.width();diff --git a/crates/editor/src/inlay_hint_cache.rs b/crates/editor/src/inlay_hint_cache.rsindex 34898aea2ef..9f9491d3de8 100644--- a/crates/editor/src/inlay_hint_cache.rs+++ b/crates/editor/src/inlay_hint_cache.rs@@ -485,6 +485,7 @@ impl InlayHintCache {self.hints.clear();}+ // TODO kb have a mappub fn hint_by_id(&self, excerpt_id: ExcerptId, hint_id: InlayId) -> Option<InlayHint> {self.hints.get(&excerpt_id)?diff --git a/crates/editor/src/link_go_to_definition.rs b/crates/editor/src/link_go_to_definition.rsindex 3de6fb872e5..8786fc8086c 100644--- a/crates/editor/src/link_go_to_definition.rs+++ b/crates/editor/src/link_go_to_definition.rs@@ -224,7 +224,6 @@ pub fn update_inlay_link_and_hover_points(extra_shift_left += 1;extra_shift_right += 1;}- // TODO kb is it right for label part cases? for `\n` in hints and fold cases?if cached_hint.padding_right {extra_shift_right += 1;}