Avoid re-rendering editor on mouse move

Only notify editor when clearing highlights if there were highlights to
begin with.

Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
Nathan Sobo 2022-10-14 18:27:55 -06:00
parent bc03592912
commit 646d344a11

View File

@ -5792,8 +5792,11 @@ impl Editor {
&mut self,
cx: &mut ViewContext<Self>,
) -> Option<(fn(&Theme) -> Color, Vec<Range<Anchor>>)> {
cx.notify();
self.background_highlights.remove(&TypeId::of::<T>())
let highlights = self.background_highlights.remove(&TypeId::of::<T>());
if highlights.is_some() {
cx.notify();
}
highlights
}
#[cfg(feature = "test-support")]
@ -5907,9 +5910,13 @@ impl Editor {
&mut self,
cx: &mut ViewContext<Self>,
) -> Option<Arc<(HighlightStyle, Vec<Range<Anchor>>)>> {
cx.notify();
self.display_map
.update(cx, |map, _| map.clear_text_highlights(TypeId::of::<T>()))
let highlights = self
.display_map
.update(cx, |map, _| map.clear_text_highlights(TypeId::of::<T>()));
if highlights.is_some() {
cx.notify();
}
highlights
}
fn next_blink_epoch(&mut self) -> usize {