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:
parent
bc03592912
commit
646d344a11
1 changed files with 12 additions and 5 deletions
|
@ -5792,8 +5792,11 @@ impl Editor {
|
||||||
&mut self,
|
&mut self,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Option<(fn(&Theme) -> Color, Vec<Range<Anchor>>)> {
|
) -> Option<(fn(&Theme) -> Color, Vec<Range<Anchor>>)> {
|
||||||
cx.notify();
|
let highlights = self.background_highlights.remove(&TypeId::of::<T>());
|
||||||
self.background_highlights.remove(&TypeId::of::<T>())
|
if highlights.is_some() {
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
highlights
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "test-support")]
|
#[cfg(feature = "test-support")]
|
||||||
|
@ -5907,9 +5910,13 @@ impl Editor {
|
||||||
&mut self,
|
&mut self,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Option<Arc<(HighlightStyle, Vec<Range<Anchor>>)>> {
|
) -> Option<Arc<(HighlightStyle, Vec<Range<Anchor>>)>> {
|
||||||
cx.notify();
|
let highlights = self
|
||||||
self.display_map
|
.display_map
|
||||||
.update(cx, |map, _| map.clear_text_highlights(TypeId::of::<T>()))
|
.update(cx, |map, _| map.clear_text_highlights(TypeId::of::<T>()));
|
||||||
|
if highlights.is_some() {
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
highlights
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_blink_epoch(&mut self) -> usize {
|
fn next_blink_epoch(&mut self) -> usize {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue