Debounce runnable refreshes in the editor (#20470)
This commit is contained in:
parent
767a82527a
commit
2b7ee1e872
1 changed files with 7 additions and 5 deletions
|
@ -9194,18 +9194,18 @@ impl Editor {
|
||||||
self.clear_tasks();
|
self.clear_tasks();
|
||||||
return Task::ready(());
|
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.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| {
|
let Ok(display_snapshot) = this.update(&mut cx, |this, cx| {
|
||||||
this.display_map.update(cx, |map, cx| map.snapshot(cx))
|
this.display_map.update(cx, |map, cx| map.snapshot(cx))
|
||||||
}) else {
|
}) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(project) = project else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
let hide_runnables = project
|
let hide_runnables = project
|
||||||
.update(&mut cx, |project, cx| {
|
.update(&mut cx, |project, cx| {
|
||||||
// Do not display any test indicators in non-dev server remote projects.
|
// 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
|
range.start..range.start
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const UPDATE_DEBOUNCE: Duration = Duration::from_millis(50);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue