Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Debounce runnable refreshes in the editor (#20470)
Kirill Bulatov2b7ee1e87295
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex e7211702525..68a0e4044ec 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -9194,18 +9194,18 @@ impl Editor {self.clear_tasks();return Task::ready(());}- let project = self.project.clone();+ let project = self.project.as_ref().map(Model::downgrade);cx.spawn(|this, mut cx| async move {+ cx.background_executor().timer(UPDATE_DEBOUNCE).await;+ let Some(project) = project.and_then(|p| p.upgrade()) else {+ return;+ };let Ok(display_snapshot) = this.update(&mut cx, |this, cx| {this.display_map.update(cx, |map, cx| map.snapshot(cx))}) else {return;};- let Some(project) = project else {- return;- };-let hide_runnables = project.update(&mut cx, |project, cx| {// Do not display any test indicators in non-dev server remote projects.@@ -14879,3 +14879,5 @@ fn check_multiline_range(buffer: &Buffer, range: Range<usize>) -> Range<usize> {range.start..range.start}}++const UPDATE_DEBOUNCE: Duration = Duration::from_millis(50);