@@ -726,7 +726,10 @@ impl EditorActionId {
726726// type GetFieldEditorTheme = dyn Fn(&theme::Theme) -> theme::FieldEditor;
727727// type OverrideTextStyle = dyn Fn(&EditorStyle) -> Option<HighlightStyle>;
728728
729- type BackgroundHighlight = (fn(&Theme) -> Hsla, Arc<[Range<Anchor>]>);
729+ type BackgroundHighlight = (
730+ Arc<dyn Fn(&usize, &Theme) -> Hsla + Send + Sync>,
731+ Arc<[Range<Anchor>]>,
732+ );
730733type GutterHighlight = (fn(&App) -> Hsla, Vec<Range<Anchor>>);
731734
732735#[derive(Default)]
@@ -6610,7 +6613,7 @@ impl Editor {
66106613 editor.update(cx, |editor, cx| {
66116614 editor.highlight_background::<Self>(
66126615 &ranges_to_highlight,
6613- |theme| theme.colors().editor_highlighted_line_background,
6616+ |_, theme| theme.colors().editor_highlighted_line_background,
66146617 cx,
66156618 );
66166619 });
@@ -7012,12 +7015,12 @@ impl Editor {
70127015
70137016 this.highlight_background::<DocumentHighlightRead>(
70147017 &read_ranges,
7015- |theme| theme.colors().editor_document_highlight_read_background,
7018+ |_, theme| theme.colors().editor_document_highlight_read_background,
70167019 cx,
70177020 );
70187021 this.highlight_background::<DocumentHighlightWrite>(
70197022 &write_ranges,
7020- |theme| theme.colors().editor_document_highlight_write_background,
7023+ |_, theme| theme.colors().editor_document_highlight_write_background,
70217024 cx,
70227025 );
70237026 cx.notify();
@@ -7125,7 +7128,7 @@ impl Editor {
71257128 if !match_ranges.is_empty() {
71267129 editor.highlight_background::<SelectedTextHighlight>(
71277130 &match_ranges,
7128- |theme| theme.colors().editor_document_highlight_bracket_background,
7131+ |_, theme| theme.colors().editor_document_highlight_bracket_background,
71297132 cx,
71307133 )
71317134 }
@@ -17519,7 +17522,7 @@ impl Editor {
1751917522 }
1752017523 editor.highlight_background::<Self>(
1752117524 &ranges,
17522- |theme| theme.colors().editor_highlighted_line_background,
17525+ |_, theme| theme.colors().editor_highlighted_line_background,
1752317526 cx,
1752417527 );
1752517528 }
@@ -20989,7 +20992,7 @@ impl Editor {
2098920992 pub fn set_search_within_ranges(&mut self, ranges: &[Range<Anchor>], cx: &mut Context<Self>) {
2099020993 self.highlight_background::<SearchWithinRange>(
2099120994 ranges,
20992- |colors| colors.colors().editor_document_highlight_read_background,
20995+ |_, colors| colors.colors().editor_document_highlight_read_background,
2099320996 cx,
2099420997 )
2099520998 }
@@ -21005,12 +21008,12 @@ impl Editor {
2100521008 pub fn highlight_background<T: 'static>(
2100621009 &mut self,
2100721010 ranges: &[Range<Anchor>],
21008- color_fetcher: fn(& Theme) -> Hsla,
21011+ color_fetcher: impl Fn(&usize, & Theme) -> Hsla + Send + Sync + 'static ,
2100921012 cx: &mut Context<Self>,
2101021013 ) {
2101121014 self.background_highlights.insert(
2101221015 HighlightKey::Type(TypeId::of::<T>()),
21013- (color_fetcher, Arc::from(ranges)),
21016+ (Arc::new( color_fetcher) , Arc::from(ranges)),
2101421017 );
2101521018 self.scrollbar_marker_state.dirty = true;
2101621019 cx.notify();
@@ -21020,12 +21023,12 @@ impl Editor {
2102021023 &mut self,
2102121024 key: usize,
2102221025 ranges: &[Range<Anchor>],
21023- color_fetcher: fn(& Theme) -> Hsla,
21026+ color_fetcher: impl Fn(&usize, & Theme) -> Hsla + Send + Sync + 'static ,
2102421027 cx: &mut Context<Self>,
2102521028 ) {
2102621029 self.background_highlights.insert(
2102721030 HighlightKey::TypePlus(TypeId::of::<T>(), key),
21028- (color_fetcher, Arc::from(ranges)),
21031+ (Arc::new( color_fetcher) , Arc::from(ranges)),
2102921032 );
2103021033 self.scrollbar_marker_state.dirty = true;
2103121034 cx.notify();
@@ -21250,7 +21253,6 @@ impl Editor {
2125021253 ) -> Vec<(Range<DisplayPoint>, Hsla)> {
2125121254 let mut results = Vec::new();
2125221255 for (color_fetcher, ranges) in self.background_highlights.values() {
21253- let color = color_fetcher(theme);
2125421256 let start_ix = match ranges.binary_search_by(|probe| {
2125521257 let cmp = probe
2125621258 .end
@@ -21263,7 +21265,7 @@ impl Editor {
2126321265 }) {
2126421266 Ok(i) | Err(i) => i,
2126521267 };
21266- for range in & ranges[start_ix..] {
21268+ for (index, range) in ranges[start_ix..].iter().enumerate() {
2126721269 if range
2126821270 .start
2126921271 .cmp(&search_range.end, &display_snapshot.buffer_snapshot())
@@ -21272,6 +21274,7 @@ impl Editor {
2127221274 break;
2127321275 }
2127421276
21277+ let color = color_fetcher(&(start_ix + index), theme);
2127521278 let start = range.start.to_display_point(display_snapshot);
2127621279 let end = range.end.to_display_point(display_snapshot);
2127721280 results.push((start..end, color))
0 commit comments