diff --git a/gpui/src/executor.rs b/gpui/src/executor.rs index 8b8b38e2ac38b9b5787f6ed5b9c7764d0286ddc9..f1fc16e53971c1b6ad9cae12bf1d3a0f2607f3e2 100644 --- a/gpui/src/executor.rs +++ b/gpui/src/executor.rs @@ -204,22 +204,13 @@ impl Background { _phantom: PhantomData, }; (scheduler)(&mut scope); - match self { - Self::Deterministic(_) => { - for spawned in scope.futures { - spawned.await; - } - } - Self::Production { executor, .. } => { - let spawned = scope - .futures - .into_iter() - .map(|f| executor.spawn(f)) - .collect::>(); - for task in spawned { - task.await; - } - } + let spawned = scope + .futures + .into_iter() + .map(|f| self.spawn(f)) + .collect::>(); + for task in spawned { + task.await; } } } diff --git a/zed/src/worktree.rs b/zed/src/worktree.rs index 22293efb5a8765510291733a2fd97c64ab2905b2..56d5c9722b76288a5ca1f0acd01e57722b03da3c 100644 --- a/zed/src/worktree.rs +++ b/zed/src/worktree.rs @@ -66,7 +66,7 @@ pub fn init(cx: &mut MutableAppContext, rpc: rpc::Client) { } #[async_trait::async_trait] -trait Fs: Send + Sync { +pub trait Fs: Send + Sync { async fn entry( &self, root_char_bag: CharBag, @@ -83,12 +83,13 @@ trait Fs: Send + Sync { ) -> Result> + Send>>>; async fn load(&self, path: &Path) -> Result; async fn save(&self, path: &Path, text: &Rope) -> Result<()>; + async fn canonicalize(&self, path: &Path) -> Result; } -struct OsFs; +struct ProductionFs; #[async_trait::async_trait] -impl Fs for OsFs { +impl Fs for ProductionFs { async fn entry( &self, root_char_bag: CharBag, @@ -183,6 +184,10 @@ impl Fs for OsFs { writer.flush().await?; Ok(()) } + + async fn canonicalize(&self, path: &Path) -> Result { + Ok(smol::fs::canonicalize(path).await?) + } } #[derive(Clone)] @@ -403,20 +408,22 @@ impl Fs for InMemoryFs { } else { let inode = state.next_inode; state.next_inode += 1; - state.entries.insert( - path.to_path_buf(), - InMemoryEntry { - inode, - mtime: SystemTime::now(), - is_dir: false, - is_symlink: false, - content: Some(text.chunks().collect()), - }, - ); + let entry = InMemoryEntry { + inode, + mtime: SystemTime::now(), + is_dir: false, + is_symlink: false, + content: Some(text.chunks().collect()), + }; + state.entries.insert(path.to_path_buf(), entry); state.emit_event(path).await; Ok(()) } } + + async fn canonicalize(&self, path: &Path) -> Result { + Ok(path.to_path_buf()) + } } #[derive(Clone, Debug)] @@ -462,7 +469,7 @@ impl Worktree { languages: Arc, cx: &mut ModelContext, ) -> Self { - let fs = Arc::new(OsFs); + let fs = Arc::new(ProductionFs); let (mut tree, scan_states_tx) = LocalWorktree::new(path, languages, fs.clone(), cx); let (event_stream, event_stream_handle) = fsevent::EventStream::new( &[tree.snapshot.abs_path.as_ref()], @@ -2169,7 +2176,7 @@ impl BackgroundScanner { break; } - if self.process_events(events).await { + if !self.process_events(events).await { break; } @@ -2339,7 +2346,7 @@ impl BackgroundScanner { let mut snapshot = self.snapshot(); snapshot.scan_id += 1; - let root_abs_path = if let Ok(abs_path) = snapshot.abs_path.canonicalize() { + let root_abs_path = if let Ok(abs_path) = self.fs.canonicalize(&snapshot.abs_path).await { abs_path } else { return false; @@ -3258,7 +3265,7 @@ mod tests { next_entry_id: Default::default(), })), notify_tx, - Arc::new(OsFs), + Arc::new(ProductionFs), Arc::new(gpui::executor::Background::new()), ); smol::block_on(scanner.scan_dirs()).unwrap();