Optimize file finder subscriptions (#8343)

Fixes #7519 

Optimizes file finder subscriptions — it now only subscribes to
worktrees updates instead of all project updates.

Project panel could also be optimized this way, I guess.

Release Notes:

- Fix selection resets in the file finder during language server
startup ([7519](https://github.com/zed-industries/zed/issues/7519))
This commit is contained in:
Andrew Lygin 2024-02-28 20:02:21 +03:00 committed by GitHub
parent 7aba9eb4b7
commit d0ffd51bb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 155 additions and 11 deletions

View file

@ -68,6 +68,11 @@ use util::{
ResultExt,
};
#[cfg(feature = "test-support")]
pub const FS_WATCH_LATENCY: Duration = Duration::from_millis(100);
#[cfg(not(feature = "test-support"))]
const FS_WATCH_LATENCY: Duration = Duration::from_millis(100);
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)]
pub struct WorktreeId(usize);
@ -652,7 +657,7 @@ fn start_background_scan_tasks(
let abs_path = abs_path.to_path_buf();
let background = cx.background_executor().clone();
async move {
let events = fs.watch(&abs_path, Duration::from_millis(100)).await;
let events = fs.watch(&abs_path, FS_WATCH_LATENCY).await;
let case_sensitive = fs.is_case_sensitive().await.unwrap_or_else(|e| {
log::error!(
"Failed to determine whether filesystem is case sensitive (falling back to true) due to error: {e:#}"
@ -4340,7 +4345,7 @@ impl BackgroundScanner {
return self.executor.simulate_random_delay().await;
}
smol::Timer::after(Duration::from_millis(100)).await;
smol::Timer::after(FS_WATCH_LATENCY).await;
}
}