From 646d344a11032c9ad2d32a7624a1254b32249716 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 14 Oct 2022 18:27:55 -0600 Subject: [PATCH] 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 --- crates/editor/src/editor.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 7f84772a452b9208463c2a233dfd57eda7c1ac52..cc8347248b8c78f1022d1d0756dc87d966631728 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -5792,8 +5792,11 @@ impl Editor { &mut self, cx: &mut ViewContext, ) -> Option<(fn(&Theme) -> Color, Vec>)> { - cx.notify(); - self.background_highlights.remove(&TypeId::of::()) + let highlights = self.background_highlights.remove(&TypeId::of::()); + if highlights.is_some() { + cx.notify(); + } + highlights } #[cfg(feature = "test-support")] @@ -5907,9 +5910,13 @@ impl Editor { &mut self, cx: &mut ViewContext, ) -> Option>)>> { - cx.notify(); - self.display_map - .update(cx, |map, _| map.clear_text_highlights(TypeId::of::())) + let highlights = self + .display_map + .update(cx, |map, _| map.clear_text_highlights(TypeId::of::())); + if highlights.is_some() { + cx.notify(); + } + highlights } fn next_blink_epoch(&mut self) -> usize {