Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
worktree: Don't attempt to watch non-existing global gitignore (#40476)
Lukas Wirthb27fd3b8d74a
diff --git a/crates/project/src/debugger/breakpoint_store.rs b/crates/project/src/debugger/breakpoint_store.rsindex b7f5360d189..42663ab9852 100644--- a/crates/project/src/debugger/breakpoint_store.rs+++ b/crates/project/src/debugger/breakpoint_store.rs@@ -164,7 +164,6 @@ pub struct BreakpointStore {impl BreakpointStore {pub fn init(client: &AnyProtoClient) {- log::error!("breakpoint store init");client.add_entity_request_handler(Self::handle_toggle_breakpoint);client.add_entity_message_handler(Self::handle_breakpoints_for_file);}diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rsindex d3aa911ae27..3fa271a37ac 100644--- a/crates/worktree/src/worktree.rs+++ b/crates/worktree/src/worktree.rs@@ -3614,25 +3614,32 @@ impl BackgroundScanner {log::trace!("containing git repository: {containing_git_repository:?}");- let mut global_gitignore_events =- if let Some(global_gitignore_path) = &paths::global_gitignore_path() {- self.state.lock().await.snapshot.global_gitignore =- if self.fs.is_file(&global_gitignore_path).await {- build_gitignore(global_gitignore_path, self.fs.as_ref())- .await- .ok()- .map(Arc::new)- } else {- None- };+ let mut global_gitignore_events = if let Some(global_gitignore_path) =+ &paths::global_gitignore_path()+ {+ let is_file = self.fs.is_file(&global_gitignore_path).await;+ self.state.lock().await.snapshot.global_gitignore = if is_file {+ build_gitignore(global_gitignore_path, self.fs.as_ref())+ .await+ .ok()+ .map(Arc::new)+ } else {+ None+ };+ if is_file+ || matches!(global_gitignore_path.parent(), Some(path) if self.fs.is_dir(path).await)+ {self.fs.watch(global_gitignore_path, FS_WATCH_LATENCY).await.0} else {- self.state.lock().await.snapshot.global_gitignore = None;- Box::pin(futures::stream::empty())- };+ Box::pin(futures::stream::pending())+ }+ } else {+ self.state.lock().await.snapshot.global_gitignore = None;+ Box::pin(futures::stream::pending())+ };let (scan_job_tx, scan_job_rx) = channel::unbounded();{@@ -3740,7 +3747,7 @@ impl BackgroundScanner {Some([event, ..]) => {self.update_global_gitignore(&event.path).await;}- _ => {},+ _ => (),}}}