Debounce runnable refreshes in the editor (#20470)

This commit is contained in:
Kirill Bulatov 2024-11-10 11:06:22 +02:00 committed by GitHub
parent 767a82527a
commit 2b7ee1e872
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);