Skip to content

Commit

Permalink
Debounce runnable refreshes in the editor (#20470)
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeoneToIgnore authored Nov 10, 2024
1 parent 767a825 commit 2b7ee1e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);

0 comments on commit 2b7ee1e

Please sign in to comment.